如何从 H.264 .TS 文件中提取视频信息?

发布于 2025-01-05 01:11:54 字数 205 浏览 1 评论 0原文

有没有好的 linux/unix 工具来获取 H264 .TS 文件的属性?

我需要持续时间、视频分辨率和比特率、fps、音频分辨率和比特率。

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

Is there any good linux/unix tool to get the properties of an H264 .TS file?

I need the duration, video resolution and bitrate, fps, audio resolution and bitrate.

I tried mplayer -vo null -ao null -frames 0 -identify _file_, but it reports wrong video width and height, and also reports the file length (duration) as 0.00.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

想念有你 2025-01-12 01:11:54

您可以运行 mediainfo(此处)并解析其输出。

mediainfo 将为您提供此类信息:

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

You can run mediainfo (here) and parse its output.

mediainfo <filename> will give you this kind of information:

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
橘虞初梦 2025-01-12 01:11:54

您应该能够使用 ffmpeg 获得编码视频的详细信息。 VLC 还会为您提供相当多的信息,但可能不是您需要的全部信息。您也可以检查一下。如果您需要更多信息,那么您可以从 TS 文件中提取视频和音频基本流(使用 bbdemux 等实用程序),然后您可以使用 Elecard 流分析器单独分析视频流。

维布杰尔

You should be able to use ffmpeg to get good details of the encoded video. VLC will also give you quite a bit of information but may not all the information you need. You can check for that as well. If you need even more information, then you can extract the video and audio elementary streams from the TS file ( using bbdemux etc utilities ) and then you can analyse the video stream separately using Elecard Stream analyzer.

Vibgyor

北风几吹夏 2025-01-12 01:11:54

对于 TS 音频和视频比特率,我编写了一个小实用程序。

它搜索 PAT 数据包,然后提取 PMT PID,然后查找 PMT 数据包并提取视频和音频数据包的 PID。之后我就能够计算整个流中音频和视频数据包的相对比例。

从总比特率(通过其他实用程序获得(例如:大小/持续时间)),然后通过简单的乘法来获取值。

注意:我不分析整个流,只分析前几兆字节。

我仍然对任何可以为我提供此信息的现有实用程序感兴趣。

For TS audio and video bitrate I wrote a small utility.

It searches for PAT packet, then extracts PMT PID, then looks up the PMT packet and extracts the PID for video and audio packets. AFter that I'm able to calculate the relative proportion of audio and video packets in the whole stream.

From the total bitrate (obtained with other utilities (eg: size/duration)) then it's a simple multiplication to get the values..

Note: I don't analyze the whole stream, only the first couple of megabytes.

I'm still interested in any existing utilities which can give me this info.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文