[MEncoder-users] howto find encoding rate of existing flv?
A. Schmid
sahib at phreaker.net
Thu May 15 18:23:50 CEST 2008
toben blalock wrote:
> Hello,
>
> I am accepting incoming flv files and re-encoding them if the bit-rate is
> greater than 500kbps.
>
> How would I check the bit-rate of an flv file through the command line?
Hmm, that seems to be a problem - that information is obviously not
present in the header ("mplayer -identify" as well as normal mplayer
output always shows a bitrate of 0). Perhaps flv is always VBR?
Of course you can calculate the approximate bitrate from file size and
playing time. For example with a small shell script:
===========================
#!/bin/sh
output=`mplayer -ao null -vo null -endpos 0 -identify "$1"`
seconds=`echo "$output" | grep ID_LENGTH | cut -d "=" -f 2`
abitrate=`echo "$output" | grep -m1 ID_AUDIO_BITRATE | cut -d "=" -f 2`
filesize=`stat -c "%s" "$1"`
echo "scale=2; (8 * $filesize / $seconds - $abitrate) / 1000 " | bc
===========================
This extracts length and audio bitrate from the header, looks up
filesize, then calculates the overall bitrate and subtracts the audio
bitrate.
This means that container overhead as well as other data streams (e.g.
subtitles, alternative audio streams) and garbage beyond the end of the
stream will also be counted into video bitrate.
It would be better and a little easier to dump the raw video stream into
an extra file, but this means extra processing overhead - I don't know
if that would be acceptable.
Regards
Alex
More information about the MEncoder-users
mailing list