diff options
author | Max Kellermann <max@duempel.org> | 2011-09-15 21:12:53 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-09-15 21:35:29 +0200 |
commit | ce35ba9ac99ed96c7f55c6d80e85fb9bfe1ed09e (patch) | |
tree | b0c692310fb48ca89b4a4e59507649d0c5a67cc0 /src/decoder/ffmpeg_decoder_plugin.c | |
parent | 724a59aaf7c396845bb5de7ad815c7ca842c2778 (diff) | |
download | mpd-ce35ba9ac99ed96c7f55c6d80e85fb9bfe1ed09e.tar.gz mpd-ce35ba9ac99ed96c7f55c6d80e85fb9bfe1ed09e.tar.xz mpd-ce35ba9ac99ed96c7f55c6d80e85fb9bfe1ed09e.zip |
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().
Diffstat (limited to 'src/decoder/ffmpeg_decoder_plugin.c')
-rw-r--r-- | src/decoder/ffmpeg_decoder_plugin.c | 13 |
1 files changed, 11 insertions, 2 deletions
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 |