MPEG 2 - 通过编辑源添加自定义标签

发布于 2024-12-02 19:17:38 字数 358 浏览 1 评论 0原文

我正在寻求建议以及我想做的事情是否可行。

我被要求创建类似于 ID3 mp3 标签的东西,可以与 MPEG 2/MPEG-TS 视频文件一起使用。因为我是一个粗鲁的人,所以我考虑在文件本身中转储某种 XML 结构。但是,这会导致尝试解码/播放视频文件的应用程序出现问题,因为应用程序不需要文件中的 XML/ASCII 数据。

我不确定是否可以有某种可以修改为 MPEG 文件末尾的 END OF FILE “命令”,并且我可以在该部分之后转储我的 XML。

就兼容性而言,我只需要避免视频文件“破坏”任何正在读取它的商业应用程序即可。标签信息将由我尚未编写的应用程序解析。

有什么想法吗?或者我所建议的是不可能的?

谢谢。

I'm looking for advice and whether what I want to do is possible.

I've been ask to create something similar to ID3 mp3 tags that can be used with MPEG 2/MPEG-TS video files. Because I'm a crude individual, I was thinking of just dumping some sort of XML structure within the file itself. However, this causes problems with applications trying to decode/play the video file as the app is not expecting XML/ASCII data in the file.

I'm not sure whether it is possible to have some sort of END OF FILE 'command' that can be amended to the end of MPEG files, and I can dump my XML after that part.

Compatibility wise, I only need avoid the video file from 'breaking' any commercial app that is reading it. The tag information will be parsed by an application I have yet to write.

Any ideas? Or is what I'm suggesting impossible?

Thanks.

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

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

发布评论

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

评论(2

温柔戏命师 2024-12-09 19:17:38

任何解码 MPEG2-TS 文件的程序都会一遍又一遍地寻找 188 字节的数据包。如果查看十六进制,您将看到一个 0x47 字节,这是每 188 字节每个数据包的同步字节(也是第一个字节)。这就是为什么向文件中添加 XML 数据会搞砸任何解码器。

您可以做的是添加自己的数据包,或者劫持通常在 MPEG2-TS 文件开头的空 PID 数据包。不幸的是,要正确执行此操作,您可能希望此数据位于网络信息表中,而该表可能尚不存在。这意味着您可能必须在 PMT 中添加对 NIT 的引用。所有这些都需要先进的知识和传输流的解析/写入能力。

您也许可以在文件开头添加数据包,而无需调整时钟参考。或者只是劫持现有的 null-PID 数据包(无需更改时钟参考)。然后在您的新数据包中使用可能不会像 8190 那样使用的数据包 ID。由于未引用 PID,在不修改 PMT 以引用 NIT 的情况下执行此操作不会是完全有效的 MPEG2-TS,但可能仍然可以工作大多数商业解码器。

我确信其中很多内容没有意义,因为您只是想添加一些标签信息而不熟悉 MPEG2-TS。但定义确切格式的标准是 ISO/IEC 13818-1。请注意,这是相当繁重的阅读。如果你想变得更轻(更便宜),你也许可以通过 wikipedia

Any program that is decoding an MPEG2-TS file will be looking for a 188 byte packet over and over again. If you look at the hex, you will see a 0x47 byte, which is the sync byte (also first byte) of every packet every 188 bytes. That is why adding XML data to the file will screw up any decoders.

What you could do is add your own packets, or hijack the null-PID packets typically at the start of an MPEG2-TS file. Unfortunately, to do this properly, you would likely want this data to be in a Network Information Table, which may not already exist. This means you may have to add a reference to the NIT in the PMT. All requiring advanced knowledge and parsing/writing capability of the transport stream.

You might be able to get away with adding packets at the start of the file without having to adjust clock references. Or just hijack the existing null-PID packets (no clock reference changes needed). Then in your new packets use a packet ID that probably won't be used like 8190. Doing this without modifying the PMT to reference a NIT would not be a completely valid MPEG2-TS because of the unreferenced PID, but would probably still work in most commercial decoders.

A lot of this is not making sense I'm sure, because you are just trying to add some tag info and not familiar with MPEG2-TS. But the standard that defines the exact format is ISO/IEC 13818-1. Beware this is pretty heavy reading. If you want to go lighter (and cheaper), you might be able to get away with just wikipedia.

小苏打饼 2024-12-09 19:17:38

有一种直接的方法来执行此 MPEG 2/MPEG-TS

基本上,您可以添加自定义描述符和/或自定义表(甚至自定义流类型),它们在流中具有自己的 PID。它们不会视频中,也不会破坏正在运行的应用程序,但可以读取它们,

为您提供视角、图文电视、VBI 数据、提示音信号、EPG、DSC-CC 命令(有些人甚至谈论使用 MPEG 系统来传输一般数据),都是通过 MPEG-T 的自定义数据示例。

详细了解 MPEG2-ISO 13818-1(有一个关于自定义表格的部分)并完善您的问题。

There is a straight forward way to do this MPEG 2/MPEG-TS

Basically you can add custom descriptors and/or custom tables (and even custom stream types) which has its' own PID in the stream. They won't be WITHIN video, and won't break working application, but they can be read

To give you perspective, Teletext, VBI data, Cue-tone signals, EPG, DSC-CC commands (and some even talk about using MPEG systems for transmitting general data), are all example of Custom data over MPEG-Ts.

Go through MPEG2- ISO 13818-1 in details (there is a section on custom tables) and refine your question.

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