2016-05-23 144 views
1

我是gstreamer的初學者,正在爲使用Gstreamer 1.0的流水線掙扎,以無縫連接兩個MP4媒體容器,這兩個媒體容器都帶有視頻和音頻流。 在我看來,使用「CONCAT」元素是最便捷的方式,我能夠Concat的任一視頻流:Gstreamer管道連接兩個媒體容器(視頻和音頻流)

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我意識到streamsynchronizer是必需的,那麼有人可以請示例管道幫助顯示它可能是什麼樣子?

+0

什麼你的意思做「至今沒有運氣」?這條管道適用於我,我可以連續播放兩個mp4視頻:'gst-launch-1.0 concat name = c! videoconvert! videoscale! autovideosink filesrc location = video1.mp4!解碼器! C。 filesrc location = video2.mp4!解碼器! c.' –

+0

@EzequielGarcia是的它的工作原理..但他需要在相同的管道音頻:) – nayana

回答

1

好吧,我想出了這一點,但有時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 ..解碼後,音頻/視頻始終爲原始格式。

2,使用2個連續元素作爲一個只能處理一個流......但如果你使用兩個連接你可能會擔心音頻/視頻不同步..我希望它是同步的,因爲他們都住在同一個管道有一個時鐘提供商的一切理論上它應該沒問題..當你需要適當的同步時,將所有東西放在一個管道中總是很重要的。

3,我用alsasink但你可以使用任何片適合你..有時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. 
+0

非常感謝!有用!你能不能請一個管道的例子,它把輸出複製到mp4並寫入到filesink中? –

+0

嗯..也許你真的需要streamsynchronizer,我還沒有讀完整個問題..到MP4混音 - 你需要重新編碼音頻/視頻和使用mp4mux和重新編碼與avenc_eac3和x264enc ..要麼更新問題或使新的一個(並發表評論,你做..) – nayana

+0

管道語法對我來說是一個黑魔法 - 玩它幾個小時,顯然我的知識是不足以解決它自己,因此張貼[下一個問題]( http://stackoverflow.com/questions/37416015/gstreamer-write-both-video-and-audo-streams-into-a-single-mp4-container-after-c) –