使用GStreamer通过WebRTC转发RTSP流时的延迟警告问题求助
GStreamer WebRTC转发RTSP流时消除延迟警告的方法
你在使用GStreamer将RTSP流通过WebRTC转发时,持续收到大量警告:
Can't determine running time for this packet without knowing configured latency
所用管道为:
rtspsrc location=my_rtsp_url is-live=true ! queue ! decodebin ! videoconvert ! openh264enc ! video/x-h264,profile=constrained-baseline ! rtph264pay aggregate-mode=zero-latency ! webrtcbin turn-server=turn://test:test@localhost:3478 bundle-policy=max-bundle name=webrtcbin
查看GStreamer源码发现RTP会话(gstrtpsession.c)中send_latency为GST_CLOCK_TIME_NONE,需要通过管道配置解决该问题。
解决方案
- 在
webrtcbin元素上添加latency属性,指定一个合理的延迟值(例如200毫秒)。修改后的管道如下:
rtspsrc location=my_rtsp_url is-live=true ! queue ! decodebin ! videoconvert ! openh264enc ! video/x-h264,profile=constrained-baseline ! rtph264pay aggregate-mode=zero-latency ! webrtcbin latency=200 turn-server=turn://test:test@localhost:3478 bundle-policy=max-bundle name=webrtcbin
- 原理:
webrtcbin内部会管理RTP会话,设置latency属性会将对应的值传递给RTP会话模块,使其能正确计算数据包的运行时间,从而消除警告。对于直播流场景,200ms是比较合理的起始值,你可以根据实际网络状况调整这个数值。
内容的提问来源于stack exchange,提问作者Dan
相关产品推荐
相关产品推荐

