将 .mov 文件转换为 .h264 文件

发布于 2024-12-01 09:10:39 字数 866 浏览 2 评论 0原文

好吧,是这样的,我实际上想从 mov 文件中解析帧。获取编码后的 h264 帧。我已经成功地通过使用 ffmpeg 做到了这一点,但是当我尝试使用 ffmpeg -i test* test.mov 再次制作电影时,我得到 test00:处理输入时发现无效数据 所以框架的结构有些不正确。据我了解,帧应该具有以下外观:

00 00 00 01 XX data -------------

其中 XX 表示它是 I、P 还是 B 帧。或者更具体地说 type(XX) = 0x0F && XX 表示它是 I(type(XX) = 5?),P(type(XX) = 7?) 还是 B(type(XX) = 8?) 帧。我不确定这些数字,我一直在寻找但没有找到好的来源。所以这是第一个问题,不同帧的 NALU 应该是多少?

无论如何,当我在 mov 文件上使用 av_read_frame 时,我得到的帧如下所示:

4B = 大小,1B = XX,然后是数据。 (至少这是我认为我得到的)

当我在十六进制编辑器中查看它们时,我存储帧的文件总是大小长(当然,否则也是如此)。 XX 在第一个帧中始终为 65(即 type(XX) = 5),然后在几帧中为 61(即 type(XX) = 1),然后在一个帧中恢复为 65,依此类推。

我猜这些帧是这样的:IPPPPPPPIPPPPPPPPPPPPPPP ....但是我对不同帧类型的类型号的假设是错误的,这很可能是错误的。 (关于阅读此内容有什么建议吗?除了 ISO/IEC 14496-10,我真的不明白)。

我尝试删除大小并在 XX 字节和数据之前附加 00 00 00 01 但没有成功。有关如何将帧修改为有效的 H264 编码帧的任何提示吗?

ok, this is the case, i actually want to parse frames from a mov file. get the encoded h264 frames. and i've managed to do so by using ffmpeg but when i try to make a movie again by using ffmpeg -i test* test.mov i get test00: Invalid data found when processing input so there is something not correct with the structure of the frames. as i understand it a frame should have the following appearance:

00 00 00 01 XX data -------------

where XX is say whether it is a I-,P- or B-frame. or more specifically type(XX) = 0x0F && XX says if it is I(type(XX) = 5?),P(type(XX) = 7?) or B(type(XX) = 8?) frame. I'm not sure about these number, i've been looking for it but not found good sources. so that's question number one, what number should the NALU be for the different frames?

anyway, when i use av_read_frame on the mov file, i get frame that look like this:

4B = size, 1B = XX and then data. (at least this is what i think i get)

the files where i store the frames are always size long when i look at them in a hexeditor(otherwise as well of course). and XX is always 65(ie. type(XX) = 5) in the first and then 61(ie. type(XX) = 1) for a couple of frames and then back to being 65 for one frame and so on.

i guess that these are frames like: I P P P P P P I P P P P P P P I P P P P P P P .... however then my assumption about the type numbers for the different frame types are false, which is highly likely. (any suggestion on reading about this? except the ISO/IEC 14496-10, i don't understand it really).

I've tried to remove the size and append 00 00 00 01 before the XX byte and the data but without success. any tips on how i could modify the frames to be valid H264 encoded frames?

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

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

发布评论

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

评论(1

忆梦 2024-12-08 09:10:39

首先,我必须推荐一个很好的工具来理解H264流: http://sourceforge.net/projects/h264bitstream /

不,要回答你的具体问题,是的,帧通常以 65 和 61 开头。通常以 67 和 68 开头的特殊 NAL 单位分别是 SPS (序列参数集)和PPS(图片参数集)。

我还建议您尝试使用 ffmpeg -i input.mov -vcodec copy output.h264 来正确获取附件 B 流(带有 00 00 00 01)作为单个文件。

我无法准确理解您想要通过从 mov 中提取帧并将其再次放入 test.mov 中来实现什么目的。

First of all, I must recommend a nice tool for understanding H264 streams: http://sourceforge.net/projects/h264bitstream/

No, to answer your specific question, yes, the frames usually start with 65 and 61. The special NAL units that typically start with 67 and 68 are, respectively, SPS (sequence parameter set) and PPS (picture parameter set).

I also suggest that you try to use ffmpeg -i input.mov -vcodec copy output.h264 to get the Annex B stream (with 00 00 00 01) correctly as a single file.

I could not understand exactly, what you are trying to achieve by extracting frames from mov and putting them into test.mov again.

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