Commit d11e2724 authored by Max Kellermann's avatar Max Kellermann

decoder/ffmpeg: use AVSEEK_FLAG_BACKWARD for seeking

Ask FFmpeg to seek to the next packet boundary *before* the seek position, so we don't miss audio data. Now we get too much, but we'll solve that in the next commit.
parent f768ca3a
......@@ -597,8 +597,12 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
av_stream->time_base) +
start_time_fallback(*av_stream);
/* AVSEEK_FLAG_BACKWARD asks FFmpeg to seek to
the packet boundary before the seek time
stamp, not after */
if (av_seek_frame(format_context, audio_stream, where,
AVSEEK_FLAG_ANY) < 0)
AVSEEK_FLAG_ANY|AVSEEK_FLAG_BACKWARD) < 0)
decoder_seek_error(decoder);
else {
avcodec_flush_buffers(codec_context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment