[FFmpeg-devel] Decoding the same audio frame twice produces different output

John Cox jc
Tue May 12 15:27:51 CEST 2009


>> Haakon Riiser wrote:
>>> As the subject states, I am wondering why libavcodec produces
>>> different output when the same audio frame is decoded twice in a
>>> row.  As far as I know, every audio frame is as independent as an
>>> I-frame in video, so it should always produce the same output.
>>>
>>>   
>> Most codec frames are dependent on the previous frame thus your  
>> statement is false.
>
>So how do you handle seeking to random locations in the stream?
>I sometimes get horribly loud artifacts when seeking, which is why
>I'm investigating this problem.  Are some audio frames the
>equivalent of key frames in video?  Can I code audio so that every
>frame is independent?

Audio isn't the same as video. In many compression methods (including mp3 and
AAC) decode of a frame of audio generates more than a frame of output samples -
some samples at the start are merged with the samples at the tail of the
previous frame and some samples at the end of the frame will be merged with the
next frame.  Thus the output samples depend on the previous frame, but you will
have "good" data from at least the 2nd decoded frame onwards.

Does that help?  For more detail you are going to need to look at the relevant
standards (or possibly Wikipedia)

John Cox



More information about the ffmpeg-devel mailing list