2012-02-14 121 views
3

有没有什么好的linux/unix工具来获取H264 .TS文件的属性?如何从H.264.TS文件中提取视频信息?

我需要时间,视频分辨率和比特率,帧,音频解析度和比特率。

我试过mplayer -vo null -ao null -frames 0 -identify _file_,但它会报告错误的视频的宽度和高度,并且还报告文件长度(持续时间)为0.00。

回答

9

您可以运行的MediaInfo(here),并分析其输出。

mediainfo <filename>会给你这样的信息:

General 
ID          : 2 (0x2) 
Format         : MPEG-TS 
File size        : 915 MiB 
Duration         : 8mn 31s 
Start time        : UTC 2009-06-09 14:15:57 
End time         : UTC 2009-06-09 14:24:12 
Overall bit rate       : 15.0 Mbps 

Video #1 
ID          : 256 (0x100) 
Menu ID         : 1 (0x1) 
Format         : AVC 
Format/Info        : Advanced Video Codec 
Format profile       : [email protected] 
Format settings, CABAC     : Yes 
Format settings, ReFrames    : 4 frames 
Codec ID         : 27 
Duration         : 8mn 31s 
Width         : 720 pixels 
Height         : 576 pixels 
Display aspect ratio      : 4:3 
Frame rate        : 25.000 fps 
Standard         : PAL 
Color space        : YUV 
Chroma subsampling      : 4:2:0 
Bit depth        : 8 bits 
Scan type        : MBAFF 
Scan order        : Top Field First 
Color primaries       : BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM 
Transfer characteristics     : BT.470-6 System B, BT.470-6 System G 
Matrix coefficients      : BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM, IEC 61966-2-4 601 

Video #2 
ID          : 1001 (0x3E9) 
Menu ID         : 3 (0x3) 
Format         : AVC 
Format/Info        : Advanced Video Codec 
Format profile       : [email protected] 
Format settings, CABAC     : Yes 
Format settings, ReFrames    : 4 frames 
Format settings, GOP      : M=3, N=24 
Codec ID         : 27 
Duration         : 8mn 30s 
Width         : 720 pixels 
Height         : 576 pixels 
Display aspect ratio      : 4:3 
Frame rate        : 25.000 fps 
Standard         : PAL 
Color space        : YUV 
Chroma subsampling      : 4:2:0 
Bit depth        : 8 bits 
Scan type        : MBAFF 
Color primaries       : BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM 
Transfer characteristics     : BT.470-6 System B, BT.470-6 System G 
Matrix coefficients      : BT.470-6 System B, BT.470-6 System G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL, BT.1700 625 SECAM, IEC 61966-2-4 601 

Audio #1 
ID          : 258 (0x102) 
Menu ID         : 1 (0x1) 
Format         : MPEG Audio 
Format version       : Version 1 
Format profile       : Layer 2 
Mode          : Joint stereo 
Mode extension       : Intensity Stereo + MS Stereo 
Codec ID         : 3 
Duration         : 8mn 31s 
Bit rate mode       : Constant 
Bit rate         : 192 Kbps 
Channel(s)        : 2 channels 
Sampling rate       : 48.0 KHz 
Compression mode       : Lossy 
Stream size        : 11.7 MiB (1%) 

Audio #2 
ID          : 1002 (0x3EA) 
Menu ID         : 3 (0x3) 
Format         : MPEG Audio 
Format version       : Version 1 
Format profile       : Layer 2 
Codec ID         : 3 
Duration         : 8mn 31s 
Bit rate mode       : Constant 
Bit rate         : 192 Kbps 
Channel(s)        : 2 channels 
Sampling rate       : 48.0 KHz 
Compression mode       : Lossy 
Delay relative to video     : 7s 978ms 
Stream size        : 11.7 MiB (1%) 

Menu #1 
ID          : 257 (0x101) 
Menu ID         : 1 (0x1) 
Duration         : 8mn 31s 
List          : 256 (0x100) (AVC)/258 (0x102) (MPEG Audio) 
Service name        : vv 
Service type        : digital television 

Menu #2 
ID          : 1000 (0x3E8) 
Menu ID         : 3 (0x3) 
Duration         : 8mn 31s 
List          : 1001 (0x3E9) (AVC)/1002 (0x3EA) (MPEG Audio) 
Service name        : Lenni 
Service type        : digital television 
1

您应该能够使用的ffmpeg获得编码视频的良好的细节。 VLC也会给你提供相当多的信息,但可能并不是你需要的所有信息。你也可以检查一下。如果您需要更多信息,则可以从TS文件(使用bbdemux等实用程序)中提取视频和音频基本流,然后使用Elecard Stream分析器分别分析视频流。

VIBGYOR

+0

1)你试过*任何这些*获得的.ts文件的时间? 2)你可以使用VLC *编程*获取信息? – 2012-02-15 15:17:20

+0

嗨,传输流(TS)是一种流媒体格式,不像AVI,MP4等是文件格式。在TS中,没有可以告诉你流的持续时间的标识符。但是,可能通过使用第一个视频数据包的时间戳和最后一个视频数据包的时间戳,您可能会得到流的持续时间。我不确定您是否可以使用VLC programmaticaly获取此信息,但您可以尝试FFMPEG。 - VIbgyor – Mukesh 2012-02-16 05:32:27

+0

谢谢,ffmpeg至少显示持续时间。不幸的是不是(a&v)流比特率。 – 2012-02-24 11:17:26

1

对于TS音频和视频比特率我写了一个小工具。

它搜索PAT包,然后提取PMT PID,然后查找的PMT包并提取PID的视频和音频数据包。之后,我能够计算整个流中音频和视频数据包的相对比例。那么它是一个简单的乘法得到的值..

注:

从总比特率(尺寸/持续时间)与其他实用程序(如获得):我不分析整个数据流,仅第一几兆字节。

我仍然有兴趣在任何现有的公用设施,可以给我这个信息。