[Libav-user] Using libavformat/libavcodec with sample accurate seeking
Christopher Snowhill
kode54 at gmail.com
Sun Aug 28 20:14:01 EEST 2016
On 8/28/16 9:56 AM, salsaman wrote:
>
>
> On Sun, Aug 28, 2016 at 1:55 PM, Christopher Snowhill
> <kode54 at gmail.com <mailto:kode54 at gmail.com>> wrote:
>
>
>
> On 8/28/16 12:50 AM, Paul B Mahol wrote:
>> Hi,
>>
>> On Sun, Aug 28, 2016 at 7:16 AM, Christopher Snowhill
>> <kode54 at gmail.com <mailto:kode54 at gmail.com>> wrote:
>>
>> I've noticed that when using these libraries in my own
>> projects, at
>> least in VGMStream, and with the WMA Pro codec, it is
>> necessary to
>> perform my own pre-roll when seeking for looping, or else the
>> codec
>> ramps the audio in from silence on every loop as it catches
>> back up to a
>> valid state. I currently use either two seconds, or the
>> beginning of the
>> file if it's less than two seconds prior to the intended seek
>> point,
>> then discard sample data that is returned by the decoder.
>>
>> Is this always necessary by design? Or am I misusing the
>> seeking API?
>>
>> I currently use:
>>
>> int64_t ts = target_sample * formatCtx->duration / total_samples;
>> avformat_seek_file(formatCtx, -1, ts - 1000, ts, ts,
>> AVSEEK_FLAG_ANY);
>>
>>
>> Do you call avcodec_flush_buffers()?
> Yes, I do. Immediately after avformat_seek_file.
>>
>>
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org <mailto:Libav-user at ffmpeg.org>
>> http://ffmpeg.org/mailman/listinfo/libav-user
>> <http://ffmpeg.org/mailman/listinfo/libav-user>
> _______________________________________________ Libav-user mailing
> list Libav-user at ffmpeg.org <mailto:Libav-user at ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/libav-user
> <http://ffmpeg.org/mailman/listinfo/libav-user>
>
> Does it make a difference if you use AV_SEEK_FLAG_BACKWARDS ?
No.
> http://lives-video.com https://www.openhub.net/accounts/salsaman
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160828/a089361e/attachment.html>
-------------- 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/20160828/a089361e/attachment.sig>
More information about the Libav-user
mailing list