1

我正在尝试使用 gst-launch-1.0 组合两个 RTSP 流,但我已经被困在尝试录制/播放一个 RTSP 流上。该流包含音频和视频。

我正在使用的命令行是:

gst-launch-1.0 ^
               rtspsrc location=<location-omitted> protocols=GST_RTSP_LOWER_TRANS_TCP latency=5000 name=s_0 ^
               s_0. ! application/x-rtp,media=audio ! rtpjitterbuffer ! decodebin ! audioconvert ! autoaudiosink ^
               s_0. ! application/x-rtp,media=video ! rtpjitterbuffer ! decodebin ! videoconvert ! autovideosink 

如果我将 autoaudiosink 更改为 fakesink,视频就会播放。如果我移除了视频接收器(没有用 fakesink 测试),音频就会播放。但如果我同时添加两者(如上),视频会显示 1 帧然后冻结。[不确定是否重要,但我在 Windows 上]

我实际上怀疑(出于某种原因)管道会暂停,但我不知道如何调试这个问题。

我尝试过使用/不使用 rtpjitterbuffer,我已经尝试过在不同的地方使用/不使用队列。我尝试过 rtp...depay/parse 的组合。尽管在过去的几个小时里我已经尝试了很多(哦哦),但我不确定我是否忽略了任何事情。

还尝试了 rtspsrc (sync/etc) 的各种选项。

但是最终结果几乎总是相同的,播放音频或视频都可以正常播放,同时播放两者(或将它们混合到一个文件中)失败。

将每个写入自己的文件都可以正常工作,例如:

gst-launch-1.0 ^
               rtspsrc location=<location-omitted> protocols=GST_RTSP_LOWER_TRANS_TCP latency=5000 name=s_0 ^
               s_0. ! application/x-rtp,media=audio ! rtpjitterbuffer ! decodebin ! audioconvert ! avenc_aac ! flvmux ! filesink location=audio.flv ^
               s_0. ! application/x-rtp,media=video ! rtpjitterbuffer ! decodebin ! videoconvert ! x264enc ! flvmux ! filesink location=video.flv

如果我将上述内容混合到一个文件中,则会发生与尝试播放文件(使用自动接收器)相同的事情,输出文件将保持为 0 字节。

尝试播放时 gst-launch-1.0 的输出与写入两个文件时的输出相同:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to <location-omitted>
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
Redistribute latency...
Redistribute latency...

不知何故,我认为这是某种同步问题,但我似乎无法弄清楚如何解决它。

4

1 回答 1

1

由于这个问题是一年多前的问题,我希望有同样问题的人仍然需要帮助(就像我一样,我花了很多时间来解决这个问题,感谢他给我提示的海报)

您需要这样编辑

gst-launch-1.0 ^
rtspsrc location=<location-omitted> protocols=GST_RTSP_LOWER_TRANS_TCP latency=5000 name=s_0 ^
s_0. ! application/x-rtp,media=audio ! rtpjitterbuffer ! decodebin ! audioconvert ! avenc_aac ! flvmux name=mux ^
s_0. ! application/x-rtp,media=video ! rtpjitterbuffer ! decodebin ! videoconvert ! x264enc ! mux. ^
mux. ! filesink location=video.flv
于 2021-08-17T03:54:30.113 回答