使用 exiftool

使用 exiftool

如何使用命令行工具获取有关视频的信息?(例如视频时长、音频编解码器、比特率等)

答案1

您可以使用多个命令来获取该信息:

avprobe从包装来看libav-tools还不错。

示例输出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

要添加 Thunar 自定义操作,根据此处的建议,要添加的模拟公式是:

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

来源:在终端中查看媒体文件信息的命令?(然后,复制)。

而且你还有:

您可以使用 MPlayer 来获取该信息。

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

来源:https://superuser.com/questions/55780/linux-command-line-tool-to-get-bitrate-of-divx-xvid

答案2

有多种方法可以实现这一点。以下是三种方法,使用三种不同的实用程序。

使用 exiftool

  1. libimage-exiftool-perl使用命令安装sudo apt-get install libimage-exiftool-perl
  2. 跑步exiftool /path/to/file
  3. 您获得的输出与此类似:

    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
    

来源:http://ubuntuforums.org/showthread.php?t=474839&p=2851338#post2851338


使用 ffmpeg

  1. ffmpeg使用命令安装sudo apt-get install ffmpeg
  2. 跑步ffmpeg -i /path/to/file
  3. 您获得的输出与此类似:

    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
    

来源:http://www.commandlinefu.com/commands/view/2207/get-video-information-with-ffmpeg


使用 mplayer

  1. mplayer使用命令安装sudo apt-get install mplayer
  2. 跑步mplayer -vo null -ao null -identify -frames 0 /path/to/file
  3. 您获得的输出与此类似:

    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
    

来源:https://superuser.com/a/55802

相关内容