Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

4 Answers 4

up vote 12 down vote accepted

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.
ID_VIDEO_ID=0
[aviheader] Video stream found, -vid 0
ID_AUDIO_ID=1
[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
ID_CLIP_INFO_NAME0=Software
ID_CLIP_INFO_VALUE0=transcode-1.0.2
ID_CLIP_INFO_N=1
ID_FILENAME=foo.avi
ID_DEMUXER=avi
ID_VIDEO_FORMAT=XVID
ID_VIDEO_BITRATE=990928
ID_VIDEO_WIDTH=512
ID_VIDEO_HEIGHT=384
ID_VIDEO_FPS=29.970
ID_VIDEO_ASPECT=0.0000
ID_AUDIO_FORMAT=85
ID_AUDIO_BITRATE=135104
ID_AUDIO_RATE=0
ID_AUDIO_NCH=0
ID_LENGTH=1288.95
ID_SEEKABLE=1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
ID_VIDEO_CODEC=ffodivx
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
ID_AUDIO_BITRATE=128000
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=2
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
AO: [null] 48000Hz 2ch s16le (2 bytes per sample)
ID_AUDIO_CODEC=mp3
Starting playback...

Exiting... (End of file)
share|improve this answer
1  
ps. the mplayer manpage is a nightmare ... –  quack quixote Oct 15 '09 at 15:18
    
For those unaware, this is essentially what midentify.sh does, the script which ships with mplayer. –  Jonah Braun 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

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
share|improve this answer

ffmpeg works fine:

ffmpeg -i file.avi
share|improve this answer
avprobe -show_streams file.avi
share|improve this answer
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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