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.

Does anyone know of a tool that would allow me to get the properties of any media file, in a parseable way? Something similar to what ImageMagick's "identify" does for images:

$ identify libre.jpg 
libre.jpg JPEG 512x512 512x512+0+0 8-bit DirectClass 102KB 0.010u 0:00.009

A Perl, Ruby or Python library would do as well.

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

ffprobe from FFmpeg can do this:

ffprobe -show_format foo.avi

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video.

share|improve this answer
    
Thanks, that helps but unfortunately the geometry properties of the stream are not part of the standard, parseable output. I guess I can parse stderr to get those but I hoped there'd be a way to do that in a stricter way. –  niXar Sep 22 '11 at 12:22
2  
Ah, -show_streams does just that. Thanks. –  niXar Sep 22 '11 at 12:23
add comment

You can use file, but it's not really consistent:

$ file test.avi
test.avi: RIFF (little-endian) data, AVI, 800 x 600, 25.00 fps, video:
$ file test.mpg
test.mpg: MPEG sequence, v1, system multiplex

Via Video file properties on the command line? - FedoraForum.org (also command line - CLI: Extract metadata, properties from video files - Ask Ubuntu) - got MediaInfo, which has a more consistent output:

$ mediainfo test.avi
General
Complete name                            : test.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 202 MiB
Duration                                 : 26s 480ms
Overall bit rate                         : 64.1 Mbps
Writing application                      : Lavf52.64.2

Video
ID                                       : 0
Format                                   : FFVH
Codec ID                                 : FFVH
Duration                                 : 26s 480ms
Bit rate                                 : 64.1 Mbps
Width                                    : 800 pixels
Height                                   : 600 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 25.000 fps
Bits/(Pixel*Frame)                       : 5.338
Stream size                              : 202 MiB (100%)


$ mediainfo test.mpg
General
Complete name                            : test.mpg
Format                                   : MPEG-PS
File size                                : 2.22 MiB
Duration                                 : 26s 480ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 704 Kbps

Video
ID                                       : 224 (0xE0)
Format                                   : MPEG Video
Format version                           : Version 1
Format settings, BVOP                    : No
Format settings, Matrix                  : Default
Format settings, GOP                     : N=12
Duration                                 : 26s 480ms
Bit rate mode                            : Variable
Bit rate                                 : 690 Kbps
Width                                    : 800 pixels
Height                                   : 600 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 25.000 fps
Color space                              : YUV
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.058
Stream size                              : 2.18 MiB (98%)

Finally, Quickly Identify Video File Attributes | SavvyAdmin.com also mentions:

Here's the output of exiftool for the same files as above:

$ exiftool test.avi 
ExifTool Version Number         : 8.15
File Name                       : test.avi
Directory                       : .
File Size                       : 202 MB
File Modification Date/Time     : 2013:09:10 16:45:02+02:00
File Permissions                : rw-r--r--
File Type                       : AVI
MIME Type                       : video/avi
Frame Rate                      : 25
Max Data Rate                   : 24.41 kB/s
Frame Count                     : 662
Stream Count                    : 1
Stream Type                     : Video
Video Codec                     : FFVH
Video Frame Rate                : 25
Video Frame Count               : 662
Quality                         : Default
Sample Size                     : Variable
Image Width                     : 800
Image Height                    : 600
Planes                          : 1
Bit Depth                       : 12
Compression                     : FFVH
Image Length                    : 1440000
Pixels Per Meter X              : 0
Pixels Per Meter Y              : 0
Num Colors                      : Use BitDepth
Num Important Colors            : All
Software                        : Lavf52.64.2
Duration                        : 26.48 s
Image Size                      : 800x600

$ exiftool test.mpg
ExifTool Version Number         : 8.15
File Name                       : test.mpg
Directory                       : .
File Size                       : 2.2 MB
File Modification Date/Time     : 2013:09:12 14:02:36+02:00
File Permissions                : rw-r--r--
File Type                       : MPEG
MIME Type                       : video/mpeg
Image Width                     : 800
Image Height                    : 600
Aspect Ratio                    : 1:1
Frame Rate                      : 25 fps
Video Bitrate                   : Variable
Image Size                      : 800x600
share|improve this answer
add comment

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.