From 3bd0b6ec8105c293cb54e1e22e201ea2cbab5d44 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 11 Aug 2018 11:59:09 +0200 Subject: [PATCH] ffmpeg: do not compute a duration for streaming streams. Streaming means the stream is endless, so don't compute a duration. ffmpeg computes an estimation using what it thinks is the file size, but is instead some internal buffer size from BAdapterIO. Fixes second part of #14326. --- src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp | 5 +++-- src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp index 8eb21e1547..1c781026c4 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp @@ -1740,8 +1740,9 @@ AVCodecDecoder::_InitFilterGraph(enum AVPixelFormat pixfmt, int32 width, fFilterGraph = avfilter_graph_alloc(); BString arguments; - arguments.SetToFormat("buffer=video_size=%dx%d:pix_fmt=%d:time_base=1/1:" - "pixel_aspect=0/1[in];[in]yadif[out];[out]buffersink", width, height, + arguments.SetToFormat("buffer=video_size=%" B_PRId32 "x%" B_PRId32 + ":pix_fmt=%d:time_base=1/1:pixel_aspect=0/1[in];[in]yadif[out];" + "[out]buffersink", width, height, pixfmt); AVFilterInOut* inputs = NULL; AVFilterInOut* outputs = NULL; diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp index 5dfa7bd75c..d09f40afa6 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp @@ -429,6 +429,12 @@ StreamBase::Duration() const // for a couple of streams and are in line with the documentation, but // unfortunately, libavformat itself seems to set the time_base and // duration wrongly sometimes. :-( + + int32 flags; + fSource->GetFlags(&flags); + if ((flags & B_MEDIA_STREAMING) != 0) + return 0; + if ((int64)fStream->duration != AV_NOPTS_VALUE) return _ConvertFromStreamTimeBase(fStream->duration); else if ((int64)fContext->duration != AV_NOPTS_VALUE)