2015-07-05 67 views
1

我使用FFMPEG到流式傳輸編碼的AAC數據的數據,我使用av_interleaved_write_frame返回0,但沒有寫入

av_interleaved_write_frame() 

寫幀。

的返回值是0 ,它意味着成功作爲description

Write a packet to an output media file ensuring correct interleaving.

The packet must contain one audio or video frame. If the packets are already correctly interleaved, the application should call av_write_frame() instead as it is slightly faster. It is also important to keep in mind that completely non-interleaved input will need huge amounts of memory to interleave with this, so it is preferable to interleave at the demuxer level.

Parameters

s media file handle

pkt The packet containing the data to be written. pkt->buf must be set to a valid AVBufferRef describing the packet data. Libavformat takes ownership of this reference and will unref it when it sees fit. The caller must not access the data through this reference after this function returns. This can be NULL (at any time, not just at the end), to flush the interleaving queues. Packet's stream_index field must be set to the index of the corresponding stream in s.streams. It is very strongly recommended that timing information (pts, dts duration) is set to correct values.

Returns

0 on success, a negative AVERROR on error.

但是,我發現沒有寫入數據。

我錯過了什麼?如何解決它?

回答

2

av_interleaved_write_frame()必須在內存中保存數據寫入它之前。交錯是取多個流(例如一個音頻流,一個視頻)並以單調順序串行化的過程。所以,如果你寫了一個音頻幀,它會一直保留在內存中,直到你寫出一個'稍後'的視頻幀。一旦後面的視頻幀被寫入,音頻幀可以被刷新'這種方式可以以不同的速度或不同的線程處理,但輸出仍然是單調的。如果你只寫了一個流(一個acc流,沒有視頻),然後按照建議使用av_write_frame()。

+0

謝謝。我使用av_write_frame而不是av_interleaved_write_frame,但是我得到崩潰錯誤:致命信號11(SIGSEGV)在0x00000000(代碼= 1),線程13608.我將調試它。如果你有一些關於它的例子,那將是完美的!再次感謝。 –

相關問題