[FFmpeg-devel] [PATCH] flv duration

Michael Niedermayer michaelni
Thu Apr 1 13:34:18 CEST 2010


On Thu, Apr 01, 2010 at 02:28:11AM -0700, Howard Chu 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.
>
> -- 
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/

> Index: libavformat/flvdec.c
> ===================================================================
> --- libavformat/flvdec.c	(revision 22757)
> +++ libavformat/flvdec.c	(working copy)
> @@ -192,9 +192,16 @@
>          } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
>              snprintf(str_val, sizeof(str_val), "%.f", num_val);
>              av_metadata_set(&s->metadata, key, str_val);
> -            if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
> -            else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
> +            if(!strcmp(key, "duration")) {

> +                s->duration = num_val * AV_TIME_BASE;
> +                s->streams[0]->duration = num_val * 1000;

you dont need to set s->duration

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100401/b0e0e4e6/attachment.pgp>



More information about the ffmpeg-devel mailing list