带 T 型杆的 Gstreamer RTSP 服务器管道

Gstreamer RTSP server pipeline with tee sticks

我正在构建一个带有三通的 gstreamer-rtsp-server(当连接客户端时)。但是,当客户端连接时,autovideosink 似乎只显示一帧并卡住。没有 tee/autovideosink,它可以工作。为什么 stick/freeze?

RTSP 服务器启动字符串:videotestsrc pattern=ball ! videoconvert ! video/x-raw, width=(int)800, height=(int)800, format=(string)I420 ! tee name=t ! x264enc ! rtph264pay name=pay0 pt=96 t. ! autovideosink

客户:gst-launch-1.0 rtspsrc protocols=tcp buffer-mode=1 location=rtsp://127.0.0.1:8554/test latency=0 ! rtph264depay ! avdec_h264 ! queue ! videoconvert ! xvimagesink sync=false

客户端输出:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://127.0.0.1:8554/test
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
0:00:20.123212962 22872 0x55f4a8b5e2d0 WARN                 rtspsrc gstrtspsrc.c:5917:gst_rtsp_src_receive_response:<rtspsrc0> error: Could not receive message. (Timeout while waiting for server response)
0:00:20.123472189 22872 0x55f4a8b5e2d0 WARN                 rtspsrc gstrtspsrc.c:7548:gst_rtspsrc_open:<rtspsrc0> can't get sdp
0:00:20.123525806 22872 0x55f4a8b5e2d0 WARN                 rtspsrc gstrtspsrc.c:5628:gst_rtspsrc_loop:<rtspsrc0> we are not connected
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not read from resource.
Additional debug info:
gstrtspsrc.c(5917): gst_rtsp_src_receive_response (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Could not receive message. (Timeout while waiting for server response)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

如文档所述,始终在每个 tee 分支后使用 queue

https://gstreamer.freedesktop.org/documentation/coreelements/tee.html?gi-language=c

One needs to use separate queue elements (or a multiqueue) in each branch to provide separate threads for each branch. Otherwise a blocked dataflow in one branch would stall the other branches.

在您的特定情况下,您还应该将 tune=zerolatency 选项添加到 x264enc 元素。这是因为默认情况下 x264enc 的延迟高于默认队列大小。或者,您需要增加队列大小以补偿 x264enc 的延迟。