M BUZZ CRAZE NEWS
// news

Get information about a video from command-line tool [duplicate]

By David Jones

How can I get information about a video with a command-line tool? (e.g. video duration, audio codec, bitrate etc)

2

2 Answers

You have several commands to get that information:

avprobe from the package libav-tools is pretty good.

Sample output avprobe somefile.mp4

avprobe version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c)
2007-2012 the Libav developers built on Nov 6 2012 16:51:33 with
gcc 4.6.3 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'somefile.mp4':
Metadata: major_brand : avc1 minor_version : 0 compatible_brands: isomavc1 creation_time : 2012-08-10 15:01:14 Duration: 00:01:02.55, start: 0.000000, bitrate: 682 kb/s Stream #0.0(und): Video: h264 (High), yuv420p, 1904x1040 [PAR 1:1 DAR 119:65], 680 kb/s, 19.18 fps, 20 tbr, 20 tbn, 40 tbc Metadata: creation_time : 2012-08-10 15:01:14

To add to Thunar custom action, in relation to what was suggested here, the analog formula to add would be:

gnome-terminal --window-with-profile=new1 -e "avprobe %f"

Source: Command to see media file info in terminal? (then, duplicated).

And also you have:

You can use MPlayer to get that information.

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

Source:

2

There are several ways to achieve this. Here are three methods, using three different utilities.

Using exiftool

  1. Install libimage-exiftool-perl using the command sudo apt-get install libimage-exiftool-perl.
  2. Run exiftool /path/to/file
  3. The output you get is similar to this:

    ExifTool Version Number : 9.04
    File Name : filename.avi
    Directory : Path/To/File
    File Size : ### MB
    File Modification Date/Time : 2013:04:14 10:46:51+04:00
    File Access Date/Time : 2013:05:19 09:21:08+04:00
    File Permissions : rwxrwxr--
    File Type : AVI
    MIME Type : video/x-msvideo
    Frame Rate : 25
    Max Data Rate : 0 kB/s
    Frame Count : 105154
    Stream Count : 2
    Stream Type : Video
    Video Codec : xvid
    Video Frame Rate : 25
    Video Frame Count : 105154
    Quality : 10000
    Sample Size : Variable
    Image Width : 640
    Image Height : 360
    Planes : 1
    Bit Depth : 12
    Compression : XVID
    Image Length : 1382400
    Pixels Per Meter X : 0
    Pixels Per Meter Y : 0
    Num Colors : Use BitDepth
    Num Important Colors : All
    Audio Codec :
    Audio Sample Rate : 41.67
    Audio Sample Count : 175252
    Encoding : MP3
    Num Channels : 2
    Sample Rate : 48000
    Avg Bytes Per Sec : 16000
    Bits Per Sample : 0
    Stream Name : filename.audio
    Duration : 1:10:06
    Image Size : 640x360

Source:


Using ffmpeg

  1. Install ffmpeg using the command sudo apt-get install ffmpeg.
  2. Run ffmpeg -i /path/to/file
  3. The output you get is similar to this:

    Input #0, avi, from 'Path/To/File': Duration: 01:10:06.16, start: 0.000000, bitrate: 1172 kb/s Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 640x360 [PAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s Metadata: title : filename.audio

Source:


Using mplayer

  1. Install mplayer using the command sudo apt-get install mplayer.
  2. Run mplayer -vo null -ao null -identify -frames 0 /path/to/file
  3. The output you get is similar to this:

    Playing Path/To/File.
    libavformat version 53.21.1 (external)
    Mismatching header version 53.19.0
    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] 640x360 12bpp 25.000 fps 1031.9 kbps (126.0 kbyte/s)
    Load subtitles in Path/To/File
    ID_FILENAME=Path/To/File
    ID_DEMUXER=avi
    ID_VIDEO_FORMAT=XVID
    ID_VIDEO_BITRATE=1031880
    ID_VIDEO_WIDTH=640
    ID_VIDEO_HEIGHT=360
    ID_VIDEO_FPS=25.000
    ID_VIDEO_ASPECT=0.0000
    ID_AUDIO_FORMAT=85
    ID_AUDIO_BITRATE=127992
    ID_AUDIO_RATE=0
    ID_AUDIO_NCH=0
    ID_START_TIME=0.00
    ID_LENGTH=4206.16
    ID_SEEKABLE=1
    ID_CHAPTERS=0
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
    libavcodec version 53.35.0 (external)
    Mismatching header version 53.32.2
    Unsupported PixelFormat 61
    Unsupported PixelFormat 53
    Unsupported PixelFormat 81
    Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
    ==========================================================================
    ID_VIDEO_CODEC=ffodivx
    ==========================================================================
    Requested audio codec family [mpg123] (afm=mpg123) not available.
    Enable it at compilation.
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, floatle, 128.0 kbit/4.17% (ratio: 16000->384000)
    ID_AUDIO_BITRATE=128000
    ID_AUDIO_RATE=48000
    ID_AUDIO_NCH=2
    Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
    ==========================================================================
    AO: [null] 48000Hz 2ch floatle (4 bytes per sample)
    ID_AUDIO_CODEC=ffmp3float
    Starting playback...
    Exiting... (End of file)
    ID_EXIT=EOF

Source:

1