ffmpeg plugin: when decoded stream duration is unavailable, attempt fallback to container duration (fix MusicPlayerDaemon/MPD#110)

This commit is contained in:
Charlie Waters 2017-09-18 01:44:47 -04:00 committed by Max Kellermann
parent ca7b4df812
commit b253a6b71e
2 changed files with 9 additions and 1 deletions

2
NEWS
View File

@ -1,6 +1,8 @@
ver 0.20.11 (not yet released) ver 0.20.11 (not yet released)
* storage * storage
- curl: support Content-Type application/xml - curl: support Content-Type application/xml
* decoder
- ffmpeg: more reliable song duration
ver 0.20.10 (2017/08/24) ver 0.20.10 (2017/08/24)
* decoder * decoder

View File

@ -712,7 +712,9 @@ FfmpegDecode(DecoderClient &client, InputStream &input,
#endif #endif
const SignedSongTime total_time = 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); client.Ready(audio_format, input.IsSeekable(), total_time);
@ -842,6 +844,10 @@ FfmpegScanStream(AVFormatContext &format_context,
tag_handler_invoke_duration(handler, handler_ctx, tag_handler_invoke_duration(handler, handler_ctx,
FromFfmpegTime(stream.duration, FromFfmpegTime(stream.duration,
stream.time_base)); 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); FfmpegScanMetadata(format_context, audio_stream, handler, handler_ctx);