diff --git a/NEWS b/NEWS index a62ed71d1..4857d2cda 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.20.11 (not yet released) * storage - curl: support Content-Type application/xml +* decoder + - ffmpeg: more reliable song duration ver 0.20.10 (2017/08/24) * decoder diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 75038e694..aba96886d 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -712,7 +712,9 @@ FfmpegDecode(DecoderClient &client, InputStream &input, #endif const SignedSongTime total_time = - FromFfmpegTimeChecked(av_stream.duration, av_stream.time_base); + av_stream.duration != (int64_t)AV_NOPTS_VALUE + ? FromFfmpegTimeChecked(av_stream.duration, av_stream.time_base) + : FromFfmpegTimeChecked(format_context.duration, AV_TIME_BASE_Q); client.Ready(audio_format, input.IsSeekable(), total_time); @@ -842,6 +844,10 @@ FfmpegScanStream(AVFormatContext &format_context, tag_handler_invoke_duration(handler, handler_ctx, FromFfmpegTime(stream.duration, stream.time_base)); + else if (format_context.duration != (int64_t)AV_NOPTS_VALUE) + tag_handler_invoke_duration(handler, handler_ctx, + FromFfmpegTime(format_context.duration, + AV_TIME_BASE_Q)); FfmpegScanMetadata(format_context, audio_stream, handler, handler_ctx);