Gstreamer 管道连接两个媒体容器(视频和音频流)

Gstreamer pipeline to concat two media containers (video and audio streams)

我是 gstreamer 的初学者,正在为 Gstreamer 1.0 的管道而苦苦挣扎,以无缝连接两个 MP4 媒体容器,它们都具有视频和音频流。 在我看来,使用 "concat" 元素是最方便的方法,我可以连接任一视频流:

gst-launch-1.0 concat name=c ! autovideosink  filesrc location=1.mp4 ! decodebin ! videoconvert ! c.  filesrc location=2.mp4 ! decodebin ! videoconvert ! c.

或音频流:

gst-launch-1.0 concat name=c ! autoaudiosink  filesrc location=1.mp4 ! decodebin ! audioconvert ! c.  filesrc location=2.mp4 ! decodebin ! audioconvert ! c.

但到目前为止,在创建将两个容器与视频和音频连接起来的管道时运气不佳。

来自 this article I realized that streamsynchronizer 是必需的,所以有人可以帮助示例管道显示它的外观吗?

好的,我想到了这个,但有时 alsa 说流不在正确的状态..

GST_DEBUG=3 gst-launch-1.0 concat name=c2 ! videoconvert ! videorate ! autovideosink concat name=c ! audioconvert ! audiorate ! alsasink filesrc location=big.mp4 ! decodebin name=d1 ! audio/x-raw ! queue ! c. filesrc location=big2.mp4 ! decodebin name=d2 ! audio/x-raw ! queue ! c. d1. ! video/x-raw ! queue ! c2. d2. ! video/x-raw ! queue ! c2.

管道信息不多:

1,您不必使用 audioconvert/videoconvert 来识别 decodebin 中的流类型 - 您可以安全地分别使用 audio/x-rawvideo/x-raw.. 在解码 audio/video 始终为原始格式。

2,使用 2 个 concat 元素,因为一个元素一次只能处理一个流。但是如果你使用两个 concat,你可能会担心 audio/video 不同步。我希望它是同步的,因为它们都生活在同一个管道中,它有一个时钟提供者来提供所有东西,所以理论上它应该没问题.. 当你需要适当的同步时,将所有东西都放在一个管道中总是很重要的。

3,我用的是alsasink,但你可以用任何适合你的sink..有时autoaudiosink会为我选择pulsesink,我不太喜欢..我喜欢使用这种音频管端:audioconvert ! audiorate ! alsasink

4,我看到了这些错误,但在添加队列后它消失了..但它们可能会出现在你面前我不知道..

0:00:00.053972316 11839 0x7f0274003b70 WARN           audiobasesink gstaudiobasesink.c:1139:gst_audio_base_sink_wait_event:<alsasink0> error: Sink not negotiated before eos event.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: The stream is in the wrong format.
Additional debug info:
gstaudiobasesink.c(1139): gst_audio_base_sink_wait_event (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Sink not negotiated before eos event.
ERROR: pipeline doesn't want to preroll.