将H.264附件B转换为MPEG-TS [英] Convert H.264 Annex B to MPEG-TS

查看:209
本文介绍了将H.264附件B转换为MPEG-TS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SO ...

我在本地文件中通过RTSP捕获了RAW H.264视频数据,我试图在Java FX应用程序中播放视频。为了做到这一点,我需要使用Http Live Streaming。

I have RAW H.264 video data captured via RTSP in a local file and I am attempting to playback the video in a Java FX application. In order to do this, I need to use Http Live Streaming.

我已经成功构建了一个Java FX架构的原型,该架构可以通过HLS与本地服务器一起使用包含.m3u8(HLS索引)文件和本地文件夹的本地文件夹播放视频.ts(MPEG-TS)文件。最后一部分是用.264 / .h264文件替换.ts文件,在本地服务器中,执行H.264附件B数据到MPEG-TS的转换/包装。

I have successfully prototyped a Java FX architecture that can play a video via HLS with a local server using a local folder containing a .m3u8 (HLS index) file and collection of .ts (MPEG-TS) files. The last piece for me is to replace the .ts files with .264 / .h264 files and in the local server, perform the conversion / wrapping of the H.264 Annex B data into MPEG-TS.

我无法确定将H.264附件B纳入MPEG-TS所需的内容。我找到了以下信息......

I am having trouble figuring out what is required to get H.264 Annex B into MPEG-TS. I have found the following information...


附件B通常用于实时和流媒体格式,例如
传输流......

"Annex B is commonly used in live and streaming formats such as transport streams..."

szatmary.org/blog/25

szatmary.org/blog/25

文件附件B指明一个这种格式以类似于传统MPEG视频基本
流的格式包装NAL
单位,因此适合与MPEG
PS / TS等无法提供所需帧的容器一起使用。 ..

"Annex B of of the document specifies one such format, which wraps NAL units in a format resembling a traditional MPEG video elementary stream, thus making it suitable for use with containers like MPEG PS/TS unable to provide the required framing..."

wiki.multimedia.cx/?title=H.264

wiki.multimedia.cx/?title=H.264

Java FX支持媒体类型是
,被认为是容器格式和一个或多个
编码的组合。在某些情况下,容器格式可能只是
基本流编码数据。

"Java FX supports a number of different media types. A media type is considered to be the combination of a container format and one or more encodings. In some cases the container format might simply be an elementary stream containing the encoded data."

docs.oracle.com/javafx/2/api/javafx/scene/media/package-summary.html

docs.oracle.com/javafx/2/api/javafx/scene/media/package-summary.html

使用CODECS属性EXT-X-STREAM-INF标签。当这个
属性存在时,它必须包含所有需要
的编解码器和配置文件来回放流......

"Use the CODECS attribute of the EXT-X-STREAM-INF tag. When this attribute is present, it must include all codecs and profiles required to play back the stream..."

developer.apple。 com / library / ios / documentation / networkinginternet / conceptual / streamingmediaguide / FrequentlyAskedQuestions / FrequentlyAskedQuestions.html

developer.apple.com/library/ios/documentation/networkinginternet/conceptual/streamingmediaguide/FrequentlyAskedQuestions/FrequentlyAskedQuestions.html

好像我错过了一些简单的东西在Elementary和Transport Streams周围。我使用ffmpeg将我的H.264文件转换为TS文件,并尝试理解差异。我对大致的格式差异有所了解,但我仍然缺乏细节。有没有人有链接展示这个或知道如何通过MPEG-TS提供H.264附件B数据?

It seems like I am missing something simple around Elementary and Transport Streams. I have used ffmpeg to convert my H.264 file into a TS file and try to understand the differences. I have an idea of the approximate format differences, but I am still lacking on the details to do it. Does anyone have a link showcasing this or know something simple about how to serve H.264 Annex B data over MPEG-TS?

我不打算使用工具,我需要在本地有一个自定义文件格式,我解析H.264附件B数据并在运行中执行内存格式更改。我知道有一种方法可以使用ffmpeg管道来实现这一目标,但我不知道苍白t具有任何依赖性和性能很重要。

I am not looking to use a tool, I need to have a custom file format locally where I parse out the H.264 Annex B data and perform the format change in memory, on the fly. I know of a way to use ffmpeg with pipes to accomplish this, but I do not want to have any dependencies and performance is important.

推荐答案

它不是格式更改。这是一个容器。无需解析附件b以将其写入TS文件。 TS包装了一个包含附件b流的PES。 mpegts格式非常复杂,特别是没有第三方库。我在工作中编写并使用的ts代码大约是1000行C ++。

Its not a format change. It is a container. There is no need to parse out annex b to write it to a TS file. The TS wraps a PES that wraps a annex b stream. The mpegts format is pretty complex, especially without a third party library. The ts code i wrote and use at work is about 1000 lines of C++.

要编写TS代码,首先尝试使用十六进制编辑器读取TS文件,然后引用维基百科文档。这本书视频揭秘也有相当好的文档。

To write TS code, start by trying to reading a TS file using a hex editor, and referencing the wikipedia documentation. The book video demystified also has fairly good documentation.

这篇关于将H.264附件B转换为MPEG-TS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆