summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharlie Waters <cawiii@me.com>2017-09-18 01:44:47 -0400
committerMax Kellermann <max@musicpd.org>2017-09-18 10:39:27 +0200
commitb253a6b71e4aaecfe8f2326b6e5b1c32d93fc83c (patch)
tree66bae1fffb63204db10761cf04ec80ee36303ce9 /src
parentca7b4df812b8109911deb1e694fbea039f9818f5 (diff)
ffmpeg plugin: when decoded stream duration is unavailable, attempt fallback to container duration (fix MusicPlayerDaemon/MPD#110)
Diffstat (limited to 'src')
-rw-r--r--src/decoder/plugins/FfmpegDecoderPlugin.cxx8
1 files changed, 7 insertions, 1 deletions
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);