From d11e2724c4f1dbe3447b3e81d0a0e71bcc504a0b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 19 Jun 2015 17:45:05 +0200 Subject: 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. --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/decoder/plugins/FfmpegDecoderPlugin.cxx') diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 586a1ef41..f5c0e0a36 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -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); -- cgit v1.2.3