Fixing Video Frame Size in WebRTC

Max

Administrator
Staff member
Try to pass valid json

Code:
curl -X POST "https://127.0.0.1:8081/rest-api/stream/find" -H "Content-Type:application/json" -d '{"name":"100000000000003","published":"true","display":"metrics"}' --insecure
 

jasonkc

Member
Try to pass valid json

Code:
curl -X POST "https://127.0.0.1:8081/rest-api/stream/find" -H "Content-Type:application/json" -d '{"name":"100000000000003","published":"true","display":"metrics"}' --insecure

I get it to work with http instead of https:

[{"appKey":"defaultApp","sessionId":"/60.51.58.97:61358/172.31.35.99:8443-67a038f3-fd36-4747-b4fc-9330d5d14d75","mediaSessionId":"3b790e00-ccdd-11eb-8a11-af470f21210f","name":"dc78","published":true,"hasVideo":true,"hasAudio":true,"status":"PUBLISHING","sdp":"v=0\r\no=mozilla...THIS_IS_SDPARTA-89.0 387822974193145200 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=fingerprint:sha-256 20:95:BA:B7:EC:04:A5:37:29:8A:6E:36:1F:7B:9A:CC:B8:29:CE:E0:EB:6F:26:08:08:4D:65:C3:11:CF:27:4C\r\na=group:BUNDLE 0 1\r\na=ice-options:trickle\r\na=msid-semantic:WMS *\r\nm=audio 9 UDP/TLS/RTP/SAVPF 109 9 0 8 101\r\nc=IN IP4 0.0.0.0\r\na=sendonly\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=fmtp:109 maxplaybackrate=48000;stereo=1;useinbandfec=1\r\na=fmtp:101 0-15\r\na=ice-pwd:a9c286a4b0a0074e4c2f900dbff1c5b2\r\na=ice-ufrag:fc6d906d\r\na=mid:0\r\na=msid:{70bb5744-91fa-40ff-a695-704c060c69a4} {7dbeff8c-0295-45cb-9526-a85dc6748346}\r\na=rtcp-mux\r\na=rtpmap:109 opus/48000/2\r\na=rtpmap:9 G722/8000/1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000/1\r\na=setup:actpass\r\na=ssrc:1883470181 cname:{09d1a0f4-f190-4e3d-a68b-119e49bc4931}\r\nm=video 9 UDP/TLS/RTP/SAVPF 120 124 121 125 126 127 97 98\r\nc=IN IP4 0.0.0.0\r\na=sendonly\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:4 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:5 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:6/recvonly http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\r\na=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1\r\na=fmtp:120 max-fs=12288;max-fr=60\r\na=fmtp:124 apt=120\r\na=fmtp:121 max-fs=12288;max-fr=60\r\na=fmtp:125 apt=121\r\na=fmtp:127 apt=126\r\na=fmtp:98 apt=97\r\na=ice-pwd:a9c286a4b0a0074e4c2f900dbff1c5b2\r\na=ice-ufrag:fc6d906d\r\na=mid:1\r\na=msid:{70bb5744-91fa-40ff-a695-704c060c69a4} {f9cbd293-3bcf-4b37-9249-65b8ef6160af}\r\na=rtcp-fb:120 nack\r\na=rtcp-fb:120 nack pli\r\na=rtcp-fb:120 ccm fir\r\na=rtcp-fb:120 goog-remb\r\na=rtcp-fb:120 transport-cc\r\na=rtcp-fb:121 nack\r\na=rtcp-fb:121 nack pli\r\na=rtcp-fb:121 ccm fir\r\na=rtcp-fb:121 goog-remb\r\na=rtcp-fb:121 transport-cc\r\na=rtcp-fb:126 nack\r\na=rtcp-fb:126 nack pli\r\na=rtcp-fb:126 ccm fir\r\na=rtcp-fb:126 goog-remb\r\na=rtcp-fb:126 transport-cc\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=rtcp-fb:97 ccm fir\r\na=rtcp-fb:97 goog-remb\r\na=rtcp-fb:97 transport-cc\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:120 VP8/90000\r\na=rtpmap:124 rtx/90000\r\na=rtpmap:121 VP9/90000\r\na=rtpmap:125 rtx/90000\r\na=rtpmap:126 H264/90000\r\na=rtpmap:127 rtx/90000\r\na=rtpmap:97 H264/90000\r\na=rtpmap:98 rtx/90000\r\na=setup:actpass\r\na=ssrc:2440072528 cname:{09d1a0f4-f190-4e3d-a68b-119e49bc4931}\r\na=ssrc:413941663 cname:{09d1a0f4-f190-4e3d-a68b-119e49bc4931}\r\na=ssrc-group:FID 2440072528 413941663\r\n","audioCodec":"opus","videoCodec":"H264","record":false,"width":640,"height":480,"bitrate":0,"minBitrate":0,"maxBitrate":0,"quality":0,"rtmpUrl":"rtmp://localhost:1935/live","history":false,"gop":0,"fps":0,"audioBitrate":0,"codecImpl":"","transport":"UDP","cvoExtension":false,"createDate":1623653609627,"mediaType":"publish","mediaProvider":"WebRTC","origin":"https://stream1-prod.jomliv.com:8888","constraints":{"audio":true,"video":{"width":720,"height":1280}}}][root@stream1-prod scripts]#


Does it mean the video frame is 1280x720?
 

Max

Administrator
Staff member
Ah yes https port is 8444
Code:
curl -X POST "https://127.0.0.1:8444/rest-api/stream/find" -H "Content-Type:application/json" -d '{"name":"100000000000003","published":"true","display":"metrics"}' --insecure
http port is 8081
Code:
curl -X POST "http://127.0.0.1:8081/rest-api/stream/find" -H "Content-Type:application/json" -d '{"name":"100000000000003","published":"true","display":"metrics"}'
 

jasonkc

Member
Is there a way to use different video constraints depending on the device/camera orientation? for instance for landscape, set it to width: 720, height: 1280; for portrait, set it to width: 1280, height: 720.
 

Max

Administrator
Staff member
Is there a way to use different video constraints depending on the device/camera orientation? for instance for landscape, set it to width: 720, height: 1280; for portrait, set it to width: 1280, height: 720.
You can detect browser and device by checking navigator.userAgent, please see example here. Then, define tha constraints depending on device, for example
JavaScript:
function publish() {
     ...
     var constraints = getConstraints();
     publishStream = session.createStream({
        name: streamName,
        display: localVideo,
        constraints: constraints
        ...
     });
     publishStream.publish();
     ...
}

function getConstraints() {
     constraints = {
        audio: true,
        video: true
     };
    
     if(isMobile()) {
        constraints.video.width=720;
        contsraints.video.height=1280;
     } else {
        constraints.video.width=1280;
        contsraints.video.height=720;
     }
    
     return constraints
}
 

jasonkc

Member
Ah yes https port is 8444
Code:
curl -X POST "https://127.0.0.1:8444/rest-api/stream/find" -H "Content-Type:application/json" -d '{"name":"100000000000003","published":"true","display":"metrics"}' --insecure
http port is 8081
Code:
curl -X POST "http://127.0.0.1:8081/rest-api/stream/find" -H "Content-Type:application/json" -d '{"name":"100000000000003","published":"true","display":"metrics"}'

I'm seeing multiple values of video width and height in the API:

curl -X POST http://127.0.0.1:8081/rest-api/stream/find -H "Content-Type:application/json" -d "name=100000000000003&published=true"
[{"appKey":"flashStreamingApp","sessionId":"/172.31.35.99:33306/127.0.0.1:1935","mediaSessionId":"61507553-7d77-429a-bc01-8215feb646c2","name":"rtmp://localhost:1935/live","published":true,"hasVideo":true,"hasAudio":true,"status":"PUBLISHING","sdp":"v=0\r\no=- 1988962254 1988962254 IN IP4 0.0.0.0\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\na=sdplang:en\r\nm=video 0 RTP/AVP 119 127\r\na=rtpmap:119 H264/90000\r\na=fmtp:119 profile-level-id=42e01f;packetization-mode=1\r\na=rtpmap:127 FLV/90000\r\na=sendonly\r\nm=audio 0 RTP/AVP 97 8 0 102 103 104 105 106 107 108 109 110\r\na=rtpmap:97 SPEEX/16000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:102 mpeg4-generic/48000/1\r\na=rtpmap:103 mpeg4-generic/44100/1\r\na=rtpmap:104 mpeg4-generic/32000/1\r\na=rtpmap:105 mpeg4-generic/24000/1\r\na=rtpmap:106 mpeg4-generic/22050/1\r\na=rtpmap:107 mpeg4-generic/16000/1\r\na=rtpmap:108 mpeg4-generic/12000/1\r\na=rtpmap:109 mpeg4-generic/11025/1\r\na=rtpmap:110 mpeg4-generic/8000/1\r\na=sendonly\r\n","audioCodec":"mpeg4-generic","videoCodec":"H264","record":false,"width":1280,"height":720,"bitrate":0,"minBitrate":0,"maxBitrate":0,"quality":0,"history":false,"gop":0,"fps":0,"audioBitrate":0,"codecImpl":"","transport":"UDP","cvoExtension":false,"createDate":1623807798439,"mediaType":"publish","mediaProvider":"Flash"},{"appKey":"flashStreamingApp","sessionId":"/127.0.0.1:42572/127.0.0.1:1935","mediaSessionId":"fa45a2ed-ade5-4423-9a33-669700ee6747","name":"rp1","published":true,"hasVideo":true,"hasAudio":true,"status":"PUBLISHING","sdp":"v=0\r\no=- 1988962254 1988962254 IN IP4 0.0.0.0\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\na=sdplang:en\r\nm=video 0 RTP/AVP 119 127\r\na=rtpmap:119 H264/90000\r\na=fmtp:119 profile-level-id=42e01f;packetization-mode=1\r\na=rtpmap:127 FLV/90000\r\na=sendonly\r\nm=audio 0 RTP/AVP 97 8 0 102 103 104 105 106 107 108 109 110\r\na=rtpmap:97 SPEEX/16000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:102 mpeg4-generic/48000/1\r\na=rtpmap:103 mpeg4-generic/44100/1\r\na=rtpmap:104 mpeg4-generic/32000/1\r\na=rtpmap:105 mpeg4-generic/24000/1\r\na=rtpmap:106 mpeg4-generic/22050/1\r\na=rtpmap:107 mpeg4-generic/16000/1\r\na=rtpmap:108 mpeg4-generic/12000/1\r\na=rtpmap:109 mpeg4-generic/11025/1\r\na=rtpmap:110 mpeg4-generic/8000/1\r\na=sendonly\r\n","audioCodec":"mpeg4-generic","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":1623759914821,"mediaType":"publish","mediaProvider":"Flash"},{"appKey":"defaultApp","sessionId":"/60.51.58.97:52346/172.31.35.99:8443-77f730cd-5c5a-4f83-b7db-534b0fde92a5","mediaSessionId":"39b5dd10-ce44-11eb-bf11-a9528d18974c","name":"100000000000003","published":true,"hasVideo":true,"hasAudio":true,"status":"PUBLISHING","sdp":"v=0\r\no=mozilla...THIS_IS_SDPARTA-89.0 3176621800161836748 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=fingerprint:sha-256 F3:0F:0A:97:8D:28:CC:C8:1B:C9:05:A1:71:9F:3E:94:63:15:29:D3:28:FE:EB:4C:A9:8B:A9:57:27:D9:AE:9B\r\na=group:BUNDLE 0 1\r\na=ice-options:trickle\r\na=msid-semantic:WMS *\r\nm=audio 9 UDP/TLS/RTP/SAVPF 109 9 0 8 101\r\nc=IN IP4 0.0.0.0\r\na=sendonly\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=fmtp:109 maxplaybackrate=48000;stereo=1;useinbandfec=1\r\na=fmtp:101 0-15\r\na=ice-pwd:41d24aa5fb444ec47025d4ab24f495c0\r\na=ice-ufrag:6c03f10a\r\na=mid:0\r\na=msid:{082edbc1-0d05-4c4f-bdfc-110abd1e218a} {57bf2cee-436c-4087-9bc2-e9c6e89f1112}\r\na=rtcp-mux\r\na=rtpmap:109 opus/48000/2\r\na=rtpmap:9 G722/8000/1\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000/1\r\na=setup:actpass\r\na=ssrc:1194781838 cname:{c4a4bf8f-94a2-41d0-8ab0-0ba941db062c}\r\nm=video 9 UDP/TLS/RTP/SAVPF 120 124 121 125 126 127 97 98\r\nc=IN IP4 0.0.0.0\r\na=sendonly\r\na=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:4 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:5 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:6/recvonly http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1\r\na=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1\r\na=fmtp:120 max-fs=12288;max-fr=60\r\na=fmtp:124 apt=120\r\na=fmtp:121 max-fs=12288;max-fr=60\r\na=fmtp:125 apt=121\r\na=fmtp:127 apt=126\r\na=fmtp:98 apt=97\r\na=ice-pwd:41d24aa5fb444ec47025d4ab24f495c0\r\na=ice-ufrag:6c03f10a\r\na=mid:1\r\na=msid:{082edbc1-0d05-4c4f-bdfc-110abd1e218a} {f11ec6c8-7fb1-477e-99f7-7c6af7fadfd9}\r\na=rtcp-fb:120 nack\r\na=rtcp-fb:120 nack pli\r\na=rtcp-fb:120 ccm fir\r\na=rtcp-fb:120 goog-remb\r\na=rtcp-fb:120 transport-cc\r\na=rtcp-fb:121 nack\r\na=rtcp-fb:121 nack pli\r\na=rtcp-fb:121 ccm fir\r\na=rtcp-fb:121 goog-remb\r\na=rtcp-fb:121 transport-cc\r\na=rtcp-fb:126 nack\r\na=rtcp-fb:126 nack pli\r\na=rtcp-fb:126 ccm fir\r\na=rtcp-fb:126 goog-remb\r\na=rtcp-fb:126 transport-cc\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=rtcp-fb:97 ccm fir\r\na=rtcp-fb:97 goog-remb\r\na=rtcp-fb:97 transport-cc\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:120 VP8/90000\r\na=rtpmap:124 rtx/90000\r\na=rtpmap:121 VP9/90000\r\na=rtpmap:125 rtx/90000\r\na=rtpmap:126 H264/90000\r\na=rtpmap:127 rtx/90000\r\na=rtpmap:97 H264/90000\r\na=rtpmap:98 rtx/90000\r\na=setup:actpass\r\na=ssrc:1691594156 cname:{c4a4bf8f-94a2-41d0-8ab0-0ba941db062c}\r\na=ssrc:849249649 cname:{c4a4bf8f-94a2-41d0-8ab0-0ba941db062c}\r\na=ssrc-group:FID 1691594156 849249649\r\n","audioCodec":"opus","videoCodec":"H264","record":false,"width":1280,"height":720,"bitrate":0,"minBitrate":0,"maxBitrate":0,"quality":0,"rtmpUrl":"rtmp://localhost:1935/live","history":false,"gop":0,"fps":0,"audioBitrate":0,"codecImpl":"","transport":"UDP","cvoExtension":false,"createDate":1623807798121,"mediaType":"publish","mediaProvider":"WebRTC","origin":"https://www.jomliv.com"},{"appKey":"flashStreamingApp","sessionId":"/127.0.0.1:45168/127.0.0.1:1935","mediaSessionId":"1000000000000031/127.0.0.1:45168/127.0.0.1:1935","name":"100000000000003","published":false,"hasVideo":true,"hasAudio":true,"status":"PLAYING","sdp":"v=0\r\no=- 1988962254 1988962254 IN IP4 0.0.0.0\r\nc=IN IP4 0.0.0.0\r\nt=0 0\r\na=sdplang:en\r\nm=video 0 RTP/AVP 96\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 profile-level-id=42e01f;packetization-mode=1\r\na=recvonly\r\nm=audio 0 RTP/AVP 97 8 0 102 103 104 105 106 107 108 109 110\r\na=rtpmap:97 SPEEX/16000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:102 mpeg4-generic/48000/1\r\na=rtpmap:103 mpeg4-generic/44100/1\r\na=rtpmap:104 mpeg4-generic/32000/1\r\na=rtpmap:105 mpeg4-generic/24000/1\r\na=rtpmap:106 mpeg4-generic/22050/1\r\na=rtpmap:107 mpeg4-generic/16000/1\r\na=rtpmap:108 mpeg4-generic/12000/1\r\na=rtpmap:109 mpeg4-generic/11025/1\r\na=rtpmap:110 mpeg4-generic/8000/1\r\na=recvonly\r\n","audioCodec":"PCMA","videoCodec":"H264","record":false,"width":1280,"height":720,"bitrate":0,"minBitrate":0,"maxBitrate":0,"quality":0,"parentMediaSessionId":"39b5dd10-ce44-11eb-bf11-a9528d18974c","history":false,"gop":0,"fps":0,"audioBitrate":0,"codecImpl":"","transport":"UDP","cvoExtension":true,"createDate":1623807801126,"mediaType":"play","mediaProvider":"Flash"}][root@stream1-prod httpd]# curl -X POST 00000000003&published=true" | jq -r '.[].width, .[].height'

e:application/json" -d "name=10000
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8824 100 8789 100 35 1287k 5248 --:--:-- --:--:-- --:--:-- 1226k
1280
1280
640
1280
1280
720
720
360
720
720

which are the actual frame size in the result? My guess is 1280x720.
 

Max

Administrator
Staff member
You see SDP supported profiles, but stream metrics is not displayed. Please correct the query:
Code:
{
 "name":"100000000000003",
 "published":true,
 "display": ["metrics"]
}
display is array, so do not miss square brackets. In this case, you will receive response like
Code:
[
  {
    "appKey": "flashStreamingApp",
    "sessionId": "/172.31.35.99:33306/127.0.0.1:1935 ",
    "mediaSessionId": "6af0baf1-f014-48d6-b285-c975951a402f",
    "name": "stream1",
    "published": true,
    "hasVideo": true,
    "hasAudio": true,
    "status": "PUBLISHING",
    "sdp": ...,
    "audioCodec": "mpeg4-generic",
    "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
    }
  }
]
The metrics VIDEO_WIDTH, VIDEO_HEIGHT show actual stream publishing resolution
 

Max

Administrator
Staff member
1623845304390.png


Try

curl -X POST "http://127.0.0.1:8081/rest-api/stream/find" -H "Content-Type:application/json" -d '{"name":"100000000000003","published":"true","display":["metrics"]}'

1623845324842.png


I have recently published stream 100000000000003 on our server and got metrics.


1623845392682.png



Please note. Parameter ["metrics"] added in version 5.2.923. If your version is older it won't work and requires update.

Version on demo.flashphoner.com is 5.2.971

1623845632277.png
 
Top