如何在 Linux 上通过命令行识别视频格式如何在 Linux 上通过命令行识别视频格式如何在 Linux 上通过命令行识别视频格式如何在 Linux 上通过命令行识别视频格式
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Linux 上通过命令行识别视频格式

如果您想知道从某处下载的视频文件使用什么视频/音频编解码器,您可以播放视频本身。大多数媒体播放器软件(例如 VLC 或 MPlayer)可以显示正在播放的视频文件的属性。但是,有一些命令行实用程序可以让您快速确定视频属性。

在本教程中,我将描述如何在 Linux 上从命令行检查视频格式。

方法一:exiftool

确定视频属性的第一种方法是使用 exiftool,它是一个综合媒体元数据查看器和编辑器。使用exiftool,您可以轻松查找给定视频文件的元数据。


$ exiftool input.mp4

ExifTool Version Number         : 8.60
File Name                       : input.mp4
Directory                       : .
File Size                       : 168 MB
File Modification Date/Time     : 2012:05:15 11:19:04-04:00
File Permissions                : rw-rw-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                     : 2012:05:14 15:18:50
Modify Date                     : 2012:05:14 15:18:50
Time Scale                      : 600
Duration                        : 0:56:32
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               : 2012:05:14 15:18:51
Track ID                        : 1
Track Duration                  : 0:56:32
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 960
Image Height                    : 720
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 960
Source Image Height             : 720
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Video Frame Rate                : 6
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2012:05:14 15:18:51
Media Modify Date               : 2012:05:14 15:18:51
Media Time Scale                : 44100
Media Duration                  : 0:56:32
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
Movie Data Size                 : 175021210
Avg Bitrate                     : 413 kbps
Image Size                      : 960x720
Rotation                        : 0

方法二:tovid

另一种识别视频格式的方法是使用tovid命令行工具,这是一个用于创建DVD的命令行工具。该工具还可以识别视频格式。

前面提到的 ExifTool 的一个问题是该工具访问的元数据可能不准确,有时甚至会产生误导。与 ExifTool 不同,tovid 实际上探测输入视频文件(通过使用 MPlayer)以获得准确的帧速率和视频速率。

要在 Ubuntu 或 Linux Mint 上安装 tovid:


$ sudo apt-get install tovid

要在其他 Linux 发行版上安装 tovid,您可以从源代码安装它。

要使用 tovid 查找视频属性,请按如下方式运行它。


$ tovid id input.mp4 

Read options from /home/dev/.tovid/tovid.ini:

--------------------------------
tovid id
Identify video files
Version 0.33
http://tovid.wikia.com
--------------------------------
Analyzing file: 'input.mp4'...
=========================================================
               File: input.mp4
              Width: 960 pixels
             Height: 720 pixels
       Aspect ratio: 1.33:1
             Frames: 20357
           Duration: 00:56:32 hours/mins/secs
          Framerate: 6.000 frames per second
       Video format: H264
      Video bitrate: 288536 bits per second
---------------------------
Audio track 1 (Stream 0.1, AID 0):
---------------------------
              Codec: aac
            Bitrate: 124000 bits per second
      Sampling rate: 44100 Hz
=========================================================
Audio is compliant with the following formats:
  Not compliant with (S)VCD or DVD
Video is compliant with the following formats:
  Not compliant with (S)VCD or DVD
This video does not seem to be compliant with (S)VCD or DVD
standards. If you burn it to a video disc, it may not work.
=========================================================

方法三:mplayer

您还可以直接从命令行使用 mplayer 来获取有关视频的信息。


$ mplayer -vo null -ao null -identify -frames 0 input.mp4

MPlayer svn r34540 (Ubuntu), built with gcc-4.7 (C) 2000-2012 MPlayer Team
Playing input.mp4.
libavformat version 53.21.0 (external)
Mismatching header version 53.19.0
libavformat file format detected.
ID_VIDEO_ID=0
[lavf] stream 0: video (h264), -vid 0
ID_AUDIO_ID=0
[lavf] stream 1: audio (aac), -aid 0, -alang und
VIDEO:  [H264]  960x720  24bpp  6.000 fps  288.5 kbps (35.2 kbyte/s)
Clip info:
 major_brand: mp42
ID_CLIP_INFO_NAME0=major_brand
ID_CLIP_INFO_VALUE0=mp42
 minor_version: 0
ID_CLIP_INFO_NAME1=minor_version
ID_CLIP_INFO_VALUE1=0
 compatible_brands: isommp42
ID_CLIP_INFO_NAME2=compatible_brands
ID_CLIP_INFO_VALUE2=isommp42
 creation_time: 2012-05-14 15:18:50
ID_CLIP_INFO_NAME3=creation_time
ID_CLIP_INFO_VALUE3=2012-05-14 15:18:50
ID_CLIP_INFO_N=4
Load subtitles in ./
ID_FILENAME=input.mp4
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=288536
ID_VIDEO_WIDTH=960
ID_VIDEO_HEIGHT=720
ID_VIDEO_FPS=6.000
ID_VIDEO_ASPECT=0.0000
ID_AUDIO_FORMAT=MP4A
ID_AUDIO_BITRATE=124144
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
ID_START_TIME=0.00
ID_LENGTH=3392.85
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
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
ID_VIDEO_CODEC=ffh264
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 124.1 kbit/8.80% (ratio: 15518->176400)
ID_AUDIO_BITRATE=124144
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [null] 44100Hz 2ch s16le (2 bytes per sample)
ID_AUDIO_CODEC=ffaac

方法四:ffmpeg

如果您的系统上安装了 FFmpeg,则可以使用 FFmpeg 从命令行检查视频编解码器信息,如下所示。


$ ffmpeg -i input.mp4

ffmpeg -i storm.mp4
ffmpeg version 0.8.6-6:0.8.6-0ubuntu0.12.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:16 with gcc 4.7.2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'storm.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2012-05-14 15:18:50
  Duration: 00:56:32.85, start: 0.000000, bitrate: 414 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 960x720, 288 kb/s, 6 fps, 6 tbr, 12 tbn, 12 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 124 kb/s
    Metadata:
      creation_time   : 2012-05-14 15:18:51
©2015-2025 艾丽卡 support@alaica.com