MPEG-2 传输流的视频尺寸(水平和垂直)

发布于 2024-11-25 01:13:15 字数 298 浏览 1 评论 0原文

我需要知道如何从 MPEG 传输流 (TS) 中获取高度和宽度以及任何其他描述性数据。

在这个答案出现之前:我很清楚视频序列头(00 00 00 B3)。这是 MPEG 节目流(即 MPEG 文件)规范的一部分,而不是 MPEG 传输流。

如果我将传输流保存到 .ts 文件中,我可以从 ffmpeg 获取此信息,但我需要能够在 ffmpeg 不可用的环境中独立于 ffmpeg 执行此操作。因此,我需要手动解析文件中的这些数据,而且除了 MPEG-TS 中的时间戳(切片开始)之外,我似乎找不到任何有关任何相关元数据的信息。

谢谢!

I need to know how to get the height and width, and any other descriptive data I can, out of an MPEG Transport Stream (TS).

Before this answer shows up: I'm well aware of the video sequence header (00 00 00 B3). That's part of the spec for an MPEG program stream (i.e. an MPEG file), not the MPEG transport stream.

If I save out a transport stream to a .ts file I can get this information from ffmpeg, but I need to be able to do it independently from ffmpeg in an environment where ffmpeg isn't available. Therefore I need to parse for this data in the file manually, and I can't seem to find ANYTHING about any relevant metadata except timestamps (slice starts) from MPEG-TS.

Thanks!

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

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

发布评论

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

评论(3

魔法少女 2024-12-02 01:13:15

恐怕您必须检查 ISO 13818-1(也称为 H.222)并阅读一些有关传输流数据包、PID 过滤和 PES 数据包的内容。

流被分成数据包。每个数据包的长度(通常)为 188 字节。数据包标头包含 PID(数据包 ID),它允许您仅过滤您感兴趣的数据包。

数据包组成 PES 数据包,其中包含 MPEG-2 数据 + 元数据(例如定时数据)。您需要构建并解析 PES 数据包,然后才能找出视频的宽度和高度。

您如何知道您对哪些 PID 感兴趣?为此,您必须阅读有关 PAT 和 PMT 的内容。 PAT 告诉您如何获取 PMT,PMT 告诉您哪些 PID 包含 MPEG-2 信息。

所有这些都在上面的文档中进行了详细描述。不过网上有很多教程和解释。例如此处,但还有很多其他的。 维基百科文章是一个很好的起点。

I'm afraid that you'll have to check ISO 13818-1 (also known as H.222) and read a bit about transport stream packets, PID filtering and PES packets.

The stream is divided into packets. Each packet is (normally) 188 bytes long. The packet header contains the PID (packet ID) which allows you to filter only the packets you're interested in.

The packets make up PES packets which hold MPEG-2 data + metadata (such as timing data). You will need to build and then parse the PES packets before you can find out the width and height of the video.

How do you know which PIDs you're interested in? For that you'll have to read about PAT and PMT. The PAT tells you how to get the PMT, and the PMT tells you which PIDs contain MPEG-2 information.

All of this is described (at length) in the documents above. But there are many tutorials and explanations online. For example here but there are many others. The Wikipedia article is a good place to start from.

心在旅行 2024-12-02 01:13:15

视频大小不是传输流的属性。这是基本视频流本身的属性。传输流或 PES 数据包不包含任何标头。

为了提取分辨率(宽度 x 高度),您必须识别 PES 起始(使用 PUSI)数据包,然后开始解析 es 标头。您需要提取 ISO/IEC 13818-第 2 部分(视频)的序列标头部分会给您答案。检查此 wiki 以获取快速参考。

Video size is NOT a property of Transport stream. This is a property of the elementary video stream itself. The transport stream or PES packet doesn't contain any header.

In order to extract the resolution (width x height) you will have to identify PES start (with PUSI) packet and then start parsing the es headers. You need to extract Sequence header part of ISO/IEC 13818-part 2 (video) will give you the answer. Check this wiki for quick reference.

桃扇骨 2024-12-02 01:13:15

实际上视频序列头(00 00 01 B3)是ISO/IEC 13818-2规范的一部分,它描述了基本视频比特流。所以传输流也会包含这个头。

这里的问题是提取此标头内容。您不能只找到此起始代码并使用其后面的字节。这可能是一项相当复杂的任务,因为:
1. 标头内容可以拆分为两个PES或传输流数据包
2. 如果传输流不仅包含视频流,则可以在某些音频或二进制数据中找到该字节序列。

Actually video sequence header (00 00 01 B3) is a part of ISO/IEC 13818-2 specification, which describes elementary video bitstream. So transport stream will contain this header too.

Problem here is to extract this header contents. You can't just find this start code and use bytes that follows it. It can be quite a complicated task because:
1. Header contents can be split into two PES or transport stream packets
2. If transport stream contains not only video stream, this sequence of bytes can be found in some audio or binary data.

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