What is a good command line tool to get the video bitrate of a divx or xvid avi file for linux?

  • ffplayer shows the current nitrate while playing video.
    – Biswapriyo
    Aug 3 '17 at 8:21

You can use MPlayer to get that information.

$ mplayer -vo null -ao null -identify -frames 0 foo.avi

In particular, you want the -identify option. The option -frames 0 tells it not to playback the file, and -vo null -ao null give it null drivers for video & audio (so you can use this command via SSH or another non-X-enabled terminal).

You can combine this with grep or other tools to pull out the specific line you want:

$ mplayer -vo null -ao null -identify -frames 0 foo.avi | grep kbps
VIDEO:  [XVID]  512x384  24bpp  29.970 fps  990.9 kbps (121.0 kbyte/s)

The full output looks like this:

$ mplayer -vo null -ao null -identify -frames 0 foo.avi
MPlayer dev-SVN-r26940 (C) 2000-2007 MPlayer Team
CPU: [hw dependent]
CPUflags:  [hw dependent]
Compiled with runtime CPU detection.

Playing foo.avi.
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [XVID]  512x384  24bpp  29.970 fps  990.9 kbps (121.0 kbyte/s)
Clip info:
 Software: transcode-1.0.2
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
AO: [null] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...

Exiting... (End of file)
  • 1
    ps. the mplayer manpage is a nightmare ... Oct 15 '09 at 15:18
  • For those unaware, this is essentially what midentify.sh does, the script which ships with mplayer. Nov 13 '11 at 23:41
  • The flags need to be updated. I get 'invalid option -- 'o' in Ubuntu 13.04
    – hnns
    Aug 19 '13 at 19:53

ffmpeg works fine:

ffmpeg -i file.avi
  • ffmpeg prevails where mplayer fails.
    – dom0
    Aug 25 '14 at 18:43
  • Some recent distributions (Debian, Ubuntu 14) dropped ffmpeg and instead shipped its libav fork, so you might need to install libav-tools and run avconv -i instead of ffmpeg -i
    – bain
    Jan 22 '15 at 17:08
  • Can you please guide me that what is video bitrate using following sample output? Input #0, flv, from 'mi-cc-03-bed_and_breakfast.flv': Duration: 00:00:18.7, start: 0.000000, bitrate: 64 kb/s Stream #0.0: Video: flv, yuv420p, 480x360, 29.92 fps(r) Stream #0.1: Audio: mp3, 44100 Hz, stereo, 64 kb/s Must supply at least one output file
    – Zain Ali
    Jul 28 '16 at 8:05
  • Zain, you pasted output with a total bitrate of 128 kb/s. "bitrate: 64 kb/s" in both video and audio sections.
    – fuzzyTew
    Jun 22 at 5:42
avprobe -show_streams file.avi
  • 1
    To show the overall bit rate, you'd be better off using -show_format, or even better (on *nix) avprobe -show_format file.avi | grep bit_rate. The same syntax will also work for ffprobe.
    – evilsoup
    Jun 25 '13 at 19:23

For video files:

Get exactly the video bitrate via mediainfo:
$ mediainfo --Output='Video;%BitRate%' '/MY/MEDIA/FILE.MP4'
or in Kbps:
$ mediainfo --Output='Video;%BitRate/String%'

Get exactly the audio bitrate via mediainfo in bps:
$ mediainfo --Output='Audio;%BitRate%' '/MY/MEDIA/FILE.MP4'
or in Kbps:
$ mediainfo --Output='Audio;%BitRate/String%' '/MY/MEDIA/FILE.MP4'

For audio files:

$ mediainfo --Inform='General;%OverallBitRate%' '/MY/MEDIA/FILE.MP3'
or in Kbps:
$ mediainfo --Inform='General;%OverallBitRate/String%' '/MY/MEDIA/FILE.MP3'

--Inform option works same as --Output here


Here's another tool that does the same thing: tcprobe, which is part of the transcode package. Use the -i switch to get an info dump from the file (sample output from the same file as in the mplayer example):

$ tcprobe -i foo.avi
[tcprobe] RIFF data, AVI video
[avilib] V: 29.970 fps, codec=XVID, frames=38630, width=512, height=384
[avilib] A: 48000 Hz, format=0x55, bits=16, channels=2, bitrate=128 kbps,
[avilib]    53707 chunks, 21768720 bytes, VBR
[tcprobe] summary for foo.avi, (*) = not default, 0 = not detected
import frame size: -g 512x384 [720x576] (*)
       frame rate: -f 29.970 [25.000] frc=4 (*)
      audio track: -a 0 [0] -e 48000,16,2 [48000,16,2] -n 0x55 [0x2000] (*)
                   bitrate=128 kbps
           length: 38630 frames, frame_time=33 msec, duration=0:21:28.954

Here is a copy-paste bash answer using avprobe (which comes with avconv and maybe ffmpeg) in case you want only the number (for further scripting)

function bitrate () { avprobe -show_format "$1" 2> /dev/null | grep "bit_rate" | sed 's/.*bit_rate=\([0-9]\+\).*/\1/g'; }

It works like this. This line gets info about the file (removing extra info on stdout):

avprobe -show_format test.mp4 2> /dev/null

Then grep selects the line which mentions bitrate

grep "bit_rate"

From which sed then extracts the bitrate (in bits/second)

sed 's/.*bit_rate=\([0-9]\+\).*/\1/g';

Long story short, copy the function in the first line and then you can do

$ bitrate test.mp4

(that's not a high-quality video, 593 kb/s, since bitrate uses 1000 instead of 1024 apparently)


I've been trying to get same info but just that data to use it in a bash loop .. and I've got it ! Using FFPROBE !

FFPROBE : hide_banner : hide header info, loglevel 0 give us only our required info, select_streams specify which stream (video) we're working on , show_entries let us specify which data specifically we want

fer@FerPC:~/Downloads/TEMP$ ffprobe -hide_banner -loglevel 0 -of flat -i 'Eng_Sub_EP.1_1_4.mkv' -select_streams v -show_entries 'format=bit_rate'

you get : format.bit_rate="1085360"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.