有谁知道有什么工具可以让我以可解析的方式获取任何媒体文件的属性?类似于 ImageMagick 的“识别”对图像的作用:
$ identify libre.jpg
libre.jpg JPEG 512x512 512x512+0+0 8-bit DirectClass 102KB 0.010u 0:00.009
Perl、Ruby 或 Python 库也可以。
答案1
答案2
您可以使用file
,但它并不真正一致:
$ 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
通过命令行上的视频文件属性? - FedoraForum.org(还命令行 - CLI:从视频文件中提取元数据、属性 - Ask Ubuntu) - 得到媒体信息,其输出更加一致:
$ 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%)
最后,快速识别视频文件属性 | SavvyAdmin.com还提到:
exiftool
以下是与上面相同文件的输出:
$ 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