Search code examples
google-chromefirefoxvideowebrtcgstreamer

WebRTC (using gstreamer and webrtcbin) works with VP9 but not with H264


I have a c++ application that gets the video in RTSP and H264 format from a camera using gstreamer an re-sends the videos using webrtcbin. I have followed the example from this link and I can see the video trough firefox (with the tips suggested in this post), when use VP9 encoding.

The pipeline I have used is:

rtspsrc location=rtsp://192.168.1.162/z3-1.mp4 ! application/x-rtp,encoding-name=H264 ! rtph264depay ! nvv4l2decoder ! nvv4l2vp9enc ! video/x-vp9 ! rtpvp9pay ! application/x-rtp,media=video,clock-rate=90000,encoding-name=VP9,payload=96,framerate=25/1 ! webrtcbin async-handling=true name=sendrecv

Although I follow the suggestion from the post), I can not see the video using Chrome but from the statistics in chrome://webrtc-internals/ it is clear that i am getting the video but chrome does not show the video.

Independently of the browser i have some issues to stream and see the video in 4k. Therefeore, i have decided to remove the VP9 enconding (to speedup the processing) and re-send the data directly in H264 from the camera. To do that i use the pipeline:

rtspsrc location=rtsp://192.168.1.162/z3-1.mp4 ! application/x-rtp,encoding-name=H264 ! webrtcbin async-handling=true name=sendrecv

After using this pipeline, i do not see the video neither in firefox or chrome. The interesing point is that if i analyze the traffic with firefox it looks like the browser is not getting any data. However in this case with chrome is getting mbytes of data but i do not see the video.

The answers of the negotiation are:

Firefox

v=0
o=mozilla...THIS_IS_SDPARTA-95.0.2 5069762040601189414 0 IN IP4 0.0.0.0
s=-
t=0 0
a=sendrecv
a=fingerprint:sha-256 ED:70:D8:AF:49:E9:B1:F8:47:83:1B:2B:13:D3:67:AD:F6:43:9D:36:59:8B:74:93:34:1D:AB:D5:67:1A:E4:07
a=ice-options:trickle
a=msid-semantic:WMS *
m=video 0 UDP/TLS/RTP/SAVPF 120
c=IN IP4 0.0.0.0
a=inactive
a=mid:video0
a=rtpmap:120 VP8/90000

Chrome

v=0
o=- 2541702691192041899 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:ssce
a=ice-pwd:eWXfMAvg/KEFxesG2nS3aNTt
a=ice-options:trickle
a=fingerprint:sha-256 E0:79:E1:50:F6:9F:CB:8B:80:8A:40:5A:B9:1B:35:27:EF:A2:45:EC:A1:A7:58:B5:24:98:0C:8D:B0:41:3B:1C
a=setup:active
a=mid:video0
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 H264/90000
a=rtcp-fb:96 nack pli
a=fmtp:96 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f

any idea about there is no video in firefox or in chrome? Any tip would be really helpful. Many thanks!


Solution

  • One possible reason browsers support only baseline profile encoded h264 streams. You can try fool browsers by add something like capssetter caps=\"application/x-rtp,profile-level-id=(string)42c015\" in between rtph264pay and webrtcbin, but it will help only in some cases.