[FFmpeg-user] FFMPEG Seeking brings audio artifacts

Gabriel Simões gabrielsimoes at rocketmail.com
Mon Nov 7 12:51:19 CET 2011


Hello,

No ideas on this one?
I´m trying to figure it out for more than 2 weeks now and can´t even imagine what is wrong.
At least any material I should go look for?

Thanks!


________________________________
From: Gabriel Simões <gabrielsimoes at rocketmail.com>
To: "ffmpeg-user at ffmpeg.org" <ffmpeg-user at ffmpeg.org>
Sent: Saturday, November 5, 2011 3:23 PM
Subject: FFMPEG Seeking brings audio artifacts


Hello!
I´m implementing a audio decoder using ffmpeg.
While reading audio and even seeking already works, I can´t figure out a way to clear the buffers after seeking so I have no artifacts when the app starts reading audio right after seeking.

avcodec_flush_buffers doesn´t seem to have any effect on the internal buffers. This issue happens with all decoders (mp3, aac, wma, ...) but PCM/WAV (which doesn´t use internal buffers to hold data to decode since the audio is not compressed).

The code snippet is simple:

    av_seek_frame(audioFilePack->avContext, audioFilePack->stream, posInTimeFrame, AVSEEK_FLAG_ANY);
    avcodec_flush_buffers(audioFilePack->avContext->streams[audioFilePack->stream]->codec);

Explaining:

    audioFilePack->avContext = FormatContext
    audioFilePack->stream = Stream Position (also used to read audio packets)
    audioFilePack->avContext->streams[audioFilePack->stream]->codec = CodecContext for the codec used

Any ideas on what I should do so I can seek and get no residual audio?

Question was also submitted to StackOverflow but I have got no answers until now:
http://stackoverflow.com/questions/7989623/ffmpeg-seeking-brings-audio-artifacts


Thanks!


More information about the ffmpeg-user mailing list