简体   繁体   English

Gstreamer H264 UDP -> WebRTC 重新流式传输

[英]Gstreamer H264 UDP -> WebRTC Restreaming

I have a Ricoh THETA Z1 360 degrees camera that outputs a 4K 360 stream. I'm using their own libuvc-theta-sample for retrieving the video stream and getting it into Gstreamer.我有一个输出 4K 360 stream 的 Ricoh THETA Z1 360 度相机。我正在使用他们自己的libuvc-theta-sample来检索视频 stream 并将其导入 Gstreamer。 I've used the following pipeline to sink the video stream to a different machine on my.network that runs a Gstreamer application that restreams udpsrc into a webrtcbin:我使用以下管道将视频 stream 下沉到 my.network 上的另一台机器,该机器运行 Gstreamer 应用程序,将 udpsrc 重新流式传输到 webrtcbin:

appsrc name=ap ! queue max-size-buffers=1 leaky=downstream ! h264parse ! rtph264pay ! udpsink host=192.168.1.137 port=1935 qos=false sync=false

On my receiving end this works perfectly fine:在我的接收端,这工作得很好: 在此处输入图像描述

As you can see I'm using a WebRTC bin that sinks the video to a WebRTC browser client.如您所见,我正在使用 WebRTC bin 将视频接收到 WebRTC 浏览器客户端。

This is all working as expected as long as I'm on localhost .只要我在 localhost 上,这一切都按预期工作。 If I try to reach the video stream from a different machine in my.network, it does the ICE and SDP offers perfectly, the WebRTC connection is established, but no video is shown.如果我尝试从 my.network 中的另一台机器访问视频 stream,它会完美地提供 ICE 和 SDP,WebRTC 连接已建立,但没有显示视频。 If I replace my pipeline with a pipeline that depays, decodes, and re-encodes the H264 stream, it works perfectly fine.如果我用一个对 H264 stream 进行解码、解码和重新编码的管道替换我的管道,它工作得很好。 Obviously, this is not what I want because I'm losing (significant) video quality and it takes time to re-encode.显然,这不是我想要的,因为我正在失去(显着的)视频质量并且重新编码需要时间。

Something that might help discover the issue is the following log that gets spammed in my console.可能有助于发现问题的是以下在我的控制台中被垃圾邮件发送的日志。 This log doesn't appear when I'm viewing the stream from localhost, but it does appear when trying to view the stream from a different machine within my.network.当我从本地主机查看 stream 时,此日志不会出现,但当我尝试从 my.network 中的另一台机器查看 stream 时,它会出现。

0:00:07.248383000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 253 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:07.559580000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 254 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:07.854883000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 255 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:08.160170000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 256 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:08.414529000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received u 0:00:07.248383000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 253 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:07.559580000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c :3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 254 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:07.854883000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 255 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:08.160170000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 256 running_time 99:99:99.999999999 all_headers 0计数 0 0:00:08.414529000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: 收到你pstream force-key-unit event, seqnum 257 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:08.715480000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 258 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:09.013550000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 259 running_time 99:99:99.999999999 all_headers 0 count 0 pstream force-key-unit event, seqnum 257 running_time 99:99:99.999999999 all_headers 0 count 0 0:00:08.715480000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 258 running_time 99 :99:99.999999999 all_headers 0 count 0 0:00:09.013550000 22700 00000139F5F3E340 INFO h264parse gsth264parse.c:3741:gst_h264_parse_src_event: received upstream force-key-unit event, seqnum 259 running_time 99:99:99.999999999 all_headers 0 count 0

I've thought about NAT traversal issues with STUN and TURN, but it wouldn't make sense as my Google Chrome WebRTC internals page shows that the WebRTC connection is successfully established.我考虑过 STUN 和 TURN 的 NAT 遍历问题,但它没有意义,因为我的 Google Chrome WebRTC 内部页面显示 WebRTC 连接已成功建立。 Besides, it does work when re-encoding the stream.此外,它在重新编码 stream 时确实有效。

I'm failing to understand why it is working on localhost, but not on other machines within my.network.我不明白为什么它在本地主机上工作,但在 my.network 中的其他机器上却没有。 Perhaps someone can shed some light on why it's not working.也许有人可以阐明为什么它不起作用。

  1. Disable firewall on streaming server and client machine then test streaming works or not.在流媒体服务器和客户端机器上禁用防火墙,然后测试流媒体是否工作。 If works then you can add your firewall rules for WebRTC and UDP ports.如果有效,那么您可以为 WebRTC 和 UDP 端口添加防火墙规则。 2)Try streaming with creating direct tunnel using ngrok or other free service with direct IP addresses. 2)尝试使用 ngrok 或其他具有直接 IP 地址的免费服务创建直接隧道进行流式传输。 Then go with STUN and TURN setup.然后是带有 STUN 和 TURN 设置的 go。

Also try following pipeline:也可以尝试以下管道:

    webrtcbin name=sendrecv bundle-policy=max-bundle
        udpsrc port=7001 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay !
        h264parse ! rtph264pay config-interval=-1 !
        queue ! application/x-rtp,media=video,encoding-name=H264,payload=96 ! rtpjitterbuffer ! sendrecv

Not sure at all for your case, but you may try adding rtpjitterbuffer with a few frames latency in the remote case:完全不确定您的情况,但您可以尝试在远程情况下添加具有几帧延迟的rtpjitterbuffer

... ! udpsrc port=1935 ! application/x-rtp,encoding-name=H264 ! rtpjitterbuffer latency=500 ! rtph264depay ! ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM