Stream parameters monitoring with REST API¶
Overview¶
WCS supports realtime stream publishing and playing parameters monitoring with REST API
Metrics available¶
Metric | Description |
---|---|
VIDEO_HEIGHT | Video height |
VIDEO_WIDTH | Video width |
VIDEO_RATE | Video bitrate |
VIDEO_SYNC | Video synchronization |
VIDEO_FPS | Video frame rate per second |
VIDEO_NACK | NACK requests count |
VIDEO_PLI | PLI packets count |
VIDEO_CODEC | Video codec |
VIDEO_K_FRAMES | Video key frames (I-frames) count |
VIDEO_P_FRAMES | Video P frames count |
VIDEO_B_FRAMES | Video B frames count |
VIDEO_GOP_SIZE | Last group of frames size between keyframes |
VIDEO_LOST | Video lost packets count |
AUDIO_SYNC | Audio synchronization |
AUDIO_RATE | Audio bitrate |
AUDIO_LOST | Lost audio packets count |
AUDIO_CODEC | Audio codec |
Receiving common stream information¶
The /stream/find
REST API query allows to find a stream by filter and
get common information about streams found. Since
build 5.2.923 stream
metrics may also be requested.
REST query should be HTTP/HTTPS POST request as follows:
- HTTP:
http://streaming.flashphoner.com:8081/rest-api/stream/find
- HTTPS:
https://streaming.flashphoner.com:8444/rest-api/stream/find
Where
streaming.flashphoner.com
- WCS server address8081
- REST / HTTP port of WCS server8444
- HTTPS port of WCS serverrest-api
- URL mandatory part/stream/find
- REST query used
REST queries and responses¶
/stream/find¶
Find a stream and display its current information
Request example¶
POST /rest-api/stream/find HTTP/1.1
Host: localhost:8081
Content-Type: application/json
{
"name":"stream1",
"published":true,
"display":["metrics"]
}
Response example¶
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
[
{
"appKey": "flashStreamingApp",
"sessionId": "/192.168.23.83:51309/192.168.130.39:1935",
"mediaSessionId": "6af0baf1-f014-48d6-b285-c975951a402f",
"name": "stream1",
"published": true,
"hasVideo": true,
"hasAudio": true,
"status": "PUBLISHING",
"sdp": ...,
"audioCodec": "mpeg4-generic/48000/2",
"videoCodec": "H264",
"record": false,
"width": 640,
"height": 360,
"bitrate": 0,
"minBitrate": 0,
"maxBitrate": 0,
"quality": 0,
"history": false,
"gop": 0,
"fps": 0,
"audioBitrate": 0,
"codecImpl": "",
"transport": "UDP",
"cvoExtension": false,
"createDate": 1616730493789,
"mediaType": "publish",
"mediaProvider": "Flash",
"metrics": {
"VIDEO_SYNC": 43688,
"VIDEO_K_FRAMES": 22,
"AUDIO_SYNC": 43712,
"VIDEO_NACK": 0,
"AUDIO_RATE": 129408,
"AUDIO_LOST": 0,
"VIDEO_LOST": 0,
"VIDEO_CODEC": 119,
"VIDEO_B_FRAMES": 0,
"VIDEO_PLI": 0,
"AUDIO_CODEC": 96,
"VIDEO_RATE": 1187440,
"VIDEO_WIDTH": 640,
"VIDEO_GOP_SIZE": 48,
"VIDEO_HEIGHT": 360,
"VIDEO_FPS": 24,
"VIDEO_P_FRAMES": 1027
}
}
]
Return codes¶
Code | Reason |
---|---|
200 | OK |
404 | Not found |
500 | Internal server error |
Parameters¶
Parameter |
Description |
Example |
---|---|---|
display | Addituional stream parameters to be in response | ["metrics"] |
mediaSessionId |
Media session Id |
6af0baf1-f014-48d6-b285-c975951a402f |
name | Stream name | stream1 |
published | Published or playing | true |
hasVideo | Is there video in the stream? | true |
hasAudio | Is there video in the stream? | true |
status | Stream status | PUBLISHING |
sdp | Stream SDP | |
audioCodec | Audio codec | mpeg4-generic |
videoCodec | Video codec | H264 |
record | Stream is recording | false |
width | Stream width at publishing moment | 640 |
height | Stream height at publishing moment | 360 |
transport | WebRTC or MPEG-TS stream transport used | UDP |
cvoExtension | WebRTC picture orientation extension is used | false |
createDate | Stream creation date | 1616730493789 |
mediaType | Media session type: publish or play | publish |
mediaProvider | Publishing or plaing stream provider (Flash for RTMP) | Flash |
minBitrate | Transcoder parameters created by REST API | |
maxBitrate | ||
quality | ||
gop | ||
fps | ||
audioBitrate | ||
codecImpl |
Audio codec details displaying¶
Since build 5.2.1619 audio track samplerate and channels count are displayed:
If there is no audio track in the stream, audioCodec will not be displayed.
Audio redundancy statistics displaying¶
Since build 5.2.2066 audio redundency statistics may be displayed by request
POST /rest-api/stream/find HTTP/1.1
Host: localhost:8081
Content-Type: application/json
{
"name":"stream1",
"published":true,
"display":["red"]
}
A published stream statistics example
{
...,
"name": "stream1",
...,
"red": {
"output": {
"totalRedundantBytes": 0,
"totalRedundantPackets": 0
},
"input": {
"totalRedundantBytes": 862151,
"usedRedundantBytes": 24115,
"totalRedundantPackets": 24633,
"usedRedundantPackets": 689
}
}
}
Where:
totalRedundantBytes
- total redundant bytes countusedRedundantBytes
- used redundant bytes counttotalRedundantPackets
- total redundant packets countusedRedundantPackets
- used redundant packets count
The statistics shows non-null values when audio redundancy support (RED) is enabled
Receiving stream metrics only¶
REST query should be HTTP/HTTPS POST request as follows:
- HTTP:
http://streaming.flashphoner.com:8081/rest-api/stream/metrics
- HTTPS:
https://streaming.flashphoner.com:8444/rest-api/stream/metrics
Where
streaming.flashphoner.com
- WCS server address8081
- REST / HTTP port of WCS server8444
- HTTPS port of WCS serverrest-api
- URL mandatory part/stream/metrics
- REST query used
REST queries and responses¶
/stream/metrics¶
Get stream metrics information
Request example¶
POST /rest-api/stream/metrics HTTP/1.1
Host: localhost:8081
Content-Type: application/json
{
"mediaSessionId" : "72b76eb8-3c01-47f3-b308-a0516d51249b"
}
POST /rest-api/stream/metrics HTTP/1.1
Host: localhost:8081
Content-Type: application/json
{
"name" : "testStream"
}
Response example¶
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
{
"VIDEO_B_FRAMES": 0,
"VIDEO_WIDTH": 1920,
"VIDEO_SYNC": 1583463093448,
"AUDIO_RATE": 31832,
"VIDEO_PLI": 0,
"VIDEO_HEIGHT": 1080,
"AUDIO_SYNC": 1583463093415,
"VIDEO_FPS": 36,
"AUDIO_CODEC": 111,
"VIDEO_P_FRAMES": 3989,
"VIDEO_RATE": 684352,
"VIDEO_CODEC": 119,
"VIDEO_K_FRAMES": 173,
"VIDEO_NACK": 1,
"VIDEO_LOST": 1,
"AUDIO_LOST": 130
}
Return codes¶
Code | Reason |
---|---|
200 | OK |
404 | Not found |
500 | Internal server error |
Parameters¶
Parameter | Description | Example |
---|---|---|
mediaSessionId | Media session identifier | 72b76eb8-3c01-47f3-b308-a0516d51249b |
name | Stream name | testStream |