[Libav-user] How to properly seek in audio?

Anton Shekhovtsov shekh.anton at gmail.com
Fri May 13 16:25:06 CEST 2016


2016-05-13 16:58 GMT+03:00 Gonzalo Garramuño <ggarra13 at gmail.com>:

> On 11/05/2016 11:46 a.m., Anton Shekhovtsov wrote:
>
>> Hello,
>>
>> I used the following code: av_seek_frame(ctx, id, pos,
>> AVSEEK_FLAG_BACKWARD);
>>
> In principle that should work for all files.  How are you calculating pos
> and selecting id?
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>

Thanks for reply.
I decided I can loop through index_entries and if there is no 'keyframes'
apply AVSEEK_FLAG_ANY.
When it comes to seeking I do not select id, I just have it. The code deals
with single stream (audio), other streams are AVDISCARD_ALL.
For pos something like this, but why do you ask?
int64_t pos = (destination_sample-discard_samples) * time_base.den /
time_base.num;
where discard_samples is magic 1024 (experimentally derived corrupt samples)
and time_base is product of stream time_base and sample_rate
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160513/ad5f74df/attachment.html>


More information about the Libav-user mailing list