Puxar metadados de um vídeo no terminal

21

Eu estou escrevendo um script que eu quero repetir os metadados (tamanho, resolução, etc.) de um conjunto de vídeos (mp4) em um arquivo.

Existe uma maneira simples de obter essas informações a partir de um arquivo MP4?

    
por Questionmark 20.05.2014 / 21:50

3 respostas

23

Em um sistema baseado no Debian (mas presumivelmente, outras distribuições também terão mediainfo em seus repositórios):

$ sudo apt-get install mediainfo
$ mediainfo foo.mp4

Isso vai espalhar muita informação. Para obter, por exemplo, comprimento, resolução, codec e dimensões, use:

$ $ mediainfo "The Blues Brothers.mp4" | grep -E 'Duration|Format  |Width|Height' | sort | uniq
Duration                                 : 2h 27mn
Format                                   : AAC
Format                                   : AVC
Format                                   : MPEG-4
Height                                   : 688 pixels
Width                                    : 1 280 pixels
    
por 20.05.2014 / 22:10
19

Você pode usar o exiftool. Para instalá-lo, execute:

sudo apt-get install libimage-exiftool-perl

Em seguida, para obter os metadados da execução do arquivo mp4:

exiftool video_file.mp4 > medatata.txt

A saída salva no arquivo deve ser algo assim:

ExifTool Version Number         : 9.60
File Name                       : video_file.mp4
Directory                       : .
File Size                       : 11 MB
File Modification Date/Time     : 2014:05:12 21:25:11+03:00
File Access Date/Time           : 2014:05:20 23:05:35+03:00
File Inode Change Date/Time     : 2014:05:12 21:25:11+03:00
File Permissions                : rw-r--r--
File Type                       : MP4
MIME Type                       : video/mp4
Major Brand                     : MP4 v2 [ISO 14496-14]
Minor Version                   : 0.0.0
Compatible Brands               : isom, mp42
Movie Header Version            : 0
Create Date                     : 2014:04:24 05:33:58
Modify Date                     : 2014:04:24 05:33:58
Time Scale                      : 600
Duration                        : 0:03:10
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 0000:00:00 00:00:00
Track Modify Date               : 2014:04:24 05:33:59
Track ID                        : 1
Track Duration                  : 0:03:10
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 450
Image Height                    : 360
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 450
Source Image Height             : 360
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Buffer Size                     : 19318
Max Bitrate                     : 1059760
Average Bitrate                 : 396688
Video Frame Rate                : 25
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2014:04:24 05:33:58
Media Modify Date               : 2014:04:24 05:33:59
Media Time Scale                : 44100
Media Duration                  : 0:03:10
Media Language Code             : und
Handler Description             : IsoMedia File Produced by Google, 5-11-2011
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Handler Type                    : Metadata
Handler Vendor ID               : Apple
Google Start Time               : 0
Google Track Duration           : 191006
Google Source Data              : B567F7685HH1399919109001385
Google Ping URL                 : 
Google Ping Message             : 
Google Host Header              : r2---sn-gqn-vhge.googlevideo.com
Movie Data Size                 : 11755744
Movie Data Offset               : 60204
Avg Bitrate                     : 493 kbps
Image Size                      : 450x360
Rotation                        : 0
    
por 20.05.2014 / 22:14
5

Você pode fazer isso com o projeto FFmpeg :

ffprobe 'Breaking The Girl-EVmfXA3vjuE.mp4'

Resultado:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Breaking The Girl-EVmfXA3vjuE.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2016-10-05T03:35:07.000000Z
  Duration: 00:04:55.38, start: 0.000000, bitrate: 330 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709),
      1280x720 [SAR 1:1 DAR 16:9], 200 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2016-10-05T03:35:07.000000Z
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp,
      125 kb/s (default)
    Metadata:
      creation_time   : 2016-10-05T03:35:07.000000Z
      handler_name    : ISO Media file produced by Google Inc.
    
por 14.11.2016 / 07:45