<p dir="ltr">Yeah I'm rolling it back 2048 samples (arbitrary) from where I want to seek to and then dropping those extra samples and it is working now. Still odd though.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Sep 11, 2016 6:24 PM, "Christopher Snowhill" <<a href="mailto:kode54@gmail.com">kode54@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 9/11/16 12:30 PM, Steve wrote:<br>
> Steve wrote<br>
>> Steve wrote<br>
>>> I'm using ffmpeg audio decoding to create a gapless audio loop. I call<br>
>>> av_seek_frame (with AVSEEK_FLAG_BACKWARD) to seek to my desired time, and<br>
>>> call avcode_flush_buffers after. It seems the first decoded frame in the<br>
>>> audio stream after the seek contains a few samples of silence or near<br>
>>> silence, thus making the loop not gapless.<br>
>>><br>
>>> If I skip an arbitrary amount of samples, the gap disappears. I've tried<br>
>>> bypassing any swr_convert resampling with same results and also using the<br>
>>> deprecated avcodec_decode_audio4 instead of the<br>
>>> avcodec_send_packet/av_read_<wbr>frame scheme.<br>
>>><br>
>>> Is there a way to know how many samples I need to skip so I exactly hit<br>
>>> the<br>
>>> actual audio data, or prevent ffmpeg from having these filler samples in<br>
>>> AVFrame->data after the seek?<br>
>> I should also mention I know that the av_seek_frame won't seek to the<br>
>> exact time requested, it's on the packet boundary. I can account for the<br>
>> number of samples I need to skip to get to the exact time, but when the<br>
>> number of samples is low (or I try without skipping these samples), the<br>
>> problem of the silence samples is evident.<br>
>><br>
>> This is using the mp3 decoder.<br>
> Incidentally this is ONLY happening with mp3 decoder (the most popular<br>
> format!). The other decoders like aac, wma, flac don't have this silence<br>
> gap. I guess it's some sort of bug.<br>
><br>
><br>
I also experience behavior like this with WMA Pro. I am forced to<br>
perform my own rollback on seeking.<br>
<br>
<br>______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a><br>
<br></blockquote></div></div>