From 43c709cd9f97b9654a8a005222647851ea3b156e Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 25 Jun 2022 00:05:57 -0700 Subject: [PATCH] [FFmpeg] Deduce the length from the container Determine the length of the file from the container, rather than the individual audio stream. The former is more likely to be set than the latter is. Signed-off-by: Christopher Snowhill --- Plugins/FFMPEG/FFMPEGDecoder.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/FFMPEG/FFMPEGDecoder.m b/Plugins/FFMPEG/FFMPEGDecoder.m index 3e0c6a172..f8190b212 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.m +++ b/Plugins/FFMPEG/FFMPEGDecoder.m @@ -424,7 +424,7 @@ static uint8_t reverse_bits[0x100]; // totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE); AVRational tb = { .num = 1, .den = codecCtx->sample_rate }; - totalFrames = isStream ? 0 : av_rescale_q(stream->duration, stream->time_base, tb); + totalFrames = isStream ? 0 : av_rescale_q(formatCtx->duration, AV_TIME_BASE_Q, tb); bitrate = (int)((codecCtx->bit_rate) / 1000); framesRead = 0; endOfStream = NO;