[FFmpeg-devel] [PATCH] parse videodatarate metadata in flv header

Arnoud Zwemmer arnoud.zwemmer
Mon Apr 7 18:12:22 CEST 2008



Michael Niedermayer wrote:
> On Tue, Apr 01, 2008 at 11:44:38AM +0200, Arnoud Zwemmer wrote:
>> Hi,
>>
>> I needed the FFmpeg summary (as shown below) to include the bitrate of 
>> video streams I'm converting, which works for many formats, but not for 
>> FLV, even if a correct 'videodatarate' metadata element is present in the 
>> FLV header.
>>
>> This patch parses the videodatarate element (not sure if there's a reason 
>> the element was not parsed before).
> [...]
> 
>> Index: flvdec.c
>> ===================================================================
>> --- flvdec.c	(revision 12661)
>> +++ flvdec.c	(working copy)
>> @@ -197,6 +197,9 @@
>>                      }
>>                  }
>>              }
>> +            else if(!strcmp(key, "videodatarate") && vcodec && num_val >= 0) {
>> +	         vcodec->bit_rate = (int)num_val * 1024;
>> +            }
> 
> tabs are forbidden in ffmpeg svn
> a >= 0 check is odd, bitrate cannot be 0
> and what is the cast good for?

Will remove tabs.

I followed handling of existing (similar) options in flvdec.c:

<...>
   else if(!strcmp(key, "videocodecid") && vcodec && 0 <= (int)num_val)
       flv_set_video_codec(s, vstream, (int)num_val);
   else if(!strcmp(key, "audiosamplesize") && acodec && 0 < (int)num_val)
<...>
   else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) {
        if (!acodec->sample_rate) {
            switch((int)num_val) {
<...>

The cast is because num_val is a double and bit_rate is an int. I agree 
the a >= 0 is a bit odd, but it's also present in the other checks.

Arnoud.





More information about the ffmpeg-devel mailing list