[FFmpeg-devel] [PATCH] flv duration

Frank Barchard fbarchard
Thu Apr 1 22:53:29 CEST 2010

On Thu, Apr 1, 2010 at 2:28 AM, Howard Chu <hyc at highlandsun.com> wrote:

> When playing an FLV, you always see this message:
> [flv @ 0x120cea0]Estimating duration from bitrate, this may be inaccurate
> even if the FLV metadata provides the duration. I'd been ignoring this for
> the most part, but after someone else mentioned it on irc I decided to take
> a look. The FLV demux sets the AVFormatContext->duration based on the
> metadata, but the av_has_duration() function wants to see it set in one of
> the AVStreams. It looks to me like it does no harm one way or the other, but
> I wrote this patch just to shut up that diagnostic.
Note that on the chromium we ran into this issue, and your change might
help.  But it affects mts and mkv as well... so we're planning to do the
following patch:

Index: media/filters/ffmpeg_demuxer.cc

--- media/filters/ffmpeg_demuxer.cc	(revision 42949)
+++ media/filters/ffmpeg_demuxer.cc	(working copy)
@@ -452,7 +452,14 @@
+  if (max_duration == base::TimeDelta() &&
+      context->duration != static_cast<int64_t>(AV_NOPTS_VALUE)) {
+    AVRational time_base = {1, base::Time::kMicrosecondsPerSecond};
+    AVRational av_time_base = {1, AV_TIME_BASE};
+    const int64 microseconds = av_rescale_q(context->duration, av_time_base,
+                                            time_base);
+    max_duration = base::TimeDelta::FromMicroseconds(microseconds);
+  }
   // Good to go: set the duration and notify we're done initializing.

More information about the ffmpeg-devel mailing list