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

最后都变了- 提交于 2019-12-04 05:13:10

问题


I am a beginner to gstreamer and struggling with a pipeline for Gstreamer 1.0 to concatenate seamlessly two MP4 media containers, both of them with video and audio streams. It seems to me that using "concat" element is the most convenient way, and I am able to concat either video streams:

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

or audio streams:

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

but no luck so far with creating a pipeline which concatenates both containers with video and audio.

From this article I realized that streamsynchronizer is required for that, so could someone please help with sample pipeline showing how it might look like ?


回答1:


Ok I came up with this but sometimes the alsa says that the stream is not in a proper state..

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.

Little info to the pipe:

1, You dont have to use audioconvert/videoconvert to recognize the type of stream from decodebin - you can safely use audio/x-raw or video/x-raw respectively.. after decoding the audio/video is always in raw format.

2, use 2 concat elements as one can only handle one stream at time.. but if you use two concats you may fear that audio/video is not synchronized.. I hope it is synced as they both live in same pipe which has one clock provider for everything so theoreticaly it should be ok.. its always important to have everything in one pipe when you need proper synchronization.

3, I used alsasink but you may use whatever sink suits you.. sometimes the autoaudiosink picked pulsesink for me which I do not like very much.. I like to use this kind of audio end of pipe: audioconvert ! audiorate ! alsasink

4, I have seen these errors but after adding queue it went away.. but they may appear for you I dont know..

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.


来源:https://stackoverflow.com/questions/37393229/gstreamer-pipeline-to-concat-two-media-containers-video-and-audio-streams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!