From ce35ba9ac99ed96c7f55c6d80e85fb9bfe1ed09e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 21:12:53 +0200 Subject: decoder/ffmpeg: explicitly specify the current stream for seeking Use AVStream.time_base to convert the decoder_seek_where() value, and pass the current stream number to av_seek_frame(). --- src/decoder/ffmpeg_decoder_plugin.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index f8c9db700..77c1a122f 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -224,6 +224,14 @@ time_from_ffmpeg(int64_t t, const AVRational time_base) / (double)1024; } +G_GNUC_CONST +static int64_t +time_to_ffmpeg(double t, const AVRational time_base) +{ + return av_rescale_q((int64_t)(t * 1024), (AVRational){1, 1024}, + time_base); +} + static enum decoder_command ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, const AVPacket *packet, @@ -445,9 +453,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) if (cmd == DECODE_COMMAND_SEEK) { int64_t where = - decoder_seek_where(decoder) * AV_TIME_BASE; + time_to_ffmpeg(decoder_seek_where(decoder), + av_stream->time_base); - if (av_seek_frame(format_context, -1, where, + if (av_seek_frame(format_context, audio_stream, where, AV_TIME_BASE) < 0) decoder_seek_error(decoder); else -- cgit v1.2.3