2014-09-05 64 views
1

Okey傢伙我認爲用gstreamer幾天後我就明白了,我寫了一些管道可以合乎邏輯地工作,但是在將流保存到文件時我感到頭疼。Gstreamer瞭解

gst-launch-1.0 rtspsrc location=rstp://ip/url ! decodebin ! textoverlay text="Work you damn thing " ! x264enc ! h264parse ! mp4mux ! filesink location=some_video.mp4 

歐凱這是我的邏輯:

1. rtspsrc - has one pad and it's src it outputs x/rtps 
2. decodebin - is a bin (bunch of elements) it has ghost pads and one of those 
    sink pads accept x/rtps then on source pad it generates raw video 
4. x264enc - accepts raw video on sink pad and encodes it to a h264 raw 
    video 
5. h264parse - accepts raw h264 on sink and it parse it to h264 video 
6. mp4mux - muxing it 
7. filesink - it sinks it to a file 

一切都很好,但之後,我完成錄製它,當我嘗試播放它,我得到這個錯誤:

This file contain no playable stream

如果有是那裏的gstreamer的一些經驗豐富的用戶,我想問他們我的邏輯漏洞在哪裏以及這個錯誤的原因是什麼?

+0

我發現它總是有用的分開管道和注入自動鏈接(autovideosink),如果需要一個解碼器逐步查看所需輸出丟失的地方。 -vvvvv標誌也提供了很多有用的信息。嘗試在textoverlay之後直接放置一個autovideosink,然後再放入一個解碼器!如果這是很好的autovideosink組合。看看mp4mux背後的視頻是否還好。 – damg 2014-09-05 07:47:17

+0

我知道了我需要-e標誌在rtpssrc之前我不知道那個標誌是什麼 – 2014-09-05 08:13:17

回答

7

您將不得不向管道發送EOS事件,然後等待管道總線上的EOS消息,然後才關閉管道(將狀態從PLAYING更改爲READY或NULL)。

如果您使用gst-launch-1.0,請使用-e參數。當你點擊ctrl + c時,它將在關閉所有內容之前完成該操作。

這是需要的,因爲最終mp4mux需要完成文件並寫入關於文件中完整流的信息。否則,該文件不是有效的MP4文件。

+0

是否因爲只有在mp4mux收到EOS之後,moov原子才被寫入文件末尾? – damg 2014-09-05 09:50:41

+0

Thx解釋。如果我可能再問一個問題,當Iam嘗試用flvmux複用音頻(filesrc)和視頻(rtspsrc)時,爲什麼gstreamer會創建24小時持續時間的文件? – 2014-09-05 12:01:59