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().
This commit is contained in:
parent
724a59aaf7
commit
ce35ba9ac9
@ -224,6 +224,14 @@ time_from_ffmpeg(int64_t t, const AVRational time_base)
|
|||||||
/ (double)1024;
|
/ (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
|
static enum decoder_command
|
||||||
ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
|
ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
|
||||||
const AVPacket *packet,
|
const AVPacket *packet,
|
||||||
@ -445,9 +453,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
|||||||
|
|
||||||
if (cmd == DECODE_COMMAND_SEEK) {
|
if (cmd == DECODE_COMMAND_SEEK) {
|
||||||
int64_t where =
|
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)
|
AV_TIME_BASE) < 0)
|
||||||
decoder_seek_error(decoder);
|
decoder_seek_error(decoder);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user