[Libav-user] Samples of silence after a av_seek_frame

Christopher Snowhill kode54 at gmail.com
Mon Sep 12 01:17:26 EEST 2016

On 9/11/16 12:30 PM, Steve wrote:
> Steve wrote
>> Steve wrote
>>> I'm using ffmpeg audio decoding to create a gapless audio loop. I call
>>> av_seek_frame (with AVSEEK_FLAG_BACKWARD) to seek to my desired time, and
>>> call avcode_flush_buffers after. It seems the first decoded frame in the
>>> audio stream after the seek contains a few samples of silence or near
>>> silence, thus making the loop not gapless.
>>> If I skip an arbitrary amount of samples, the gap disappears. I've tried
>>> bypassing any swr_convert resampling with same results and also using the
>>> deprecated avcodec_decode_audio4 instead of the
>>> avcodec_send_packet/av_read_frame scheme.
>>> Is there a way to know how many samples I need to skip so I exactly hit
>>> the
>>> actual audio data, or prevent ffmpeg from having these filler samples in
>>> AVFrame->data after the seek?
>> I should also mention I know that the av_seek_frame won't seek to the
>> exact time requested, it's on the packet boundary. I can account for the
>> number of samples I need to skip to get to the exact time, but when the
>> number of samples is low (or I try without skipping these samples), the
>> problem of the silence samples is evident.
>> This is using the mp3 decoder.
> Incidentally this is ONLY happening with mp3 decoder (the most popular
> format!). The other decoders like aac, wma, flac don't have this silence
> gap. I guess it's some sort of bug.
I also experience behavior like this with WMA Pro. I am forced to
perform my own rollback on seeking.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160911/09cb30d2/attachment.sig>

More information about the Libav-user mailing list