简体   繁体   English

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

[英]converting .mov file to .h264 file

ok, this is the case, i actually want to parse frames from a mov file. 好的,就是这种情况,我实际上想解析一个mov文件中的帧。 get the encoded h264 frames. 获取编码的h264帧。 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. 并且我已经设法通过使用ffmpeg这样做但当我尝试使用ffmpeg -i test* test.mov再次制作电影时我得到test00: Invalid data found when processing input所以有一些不正确的结构框架。 as i understand it a frame should have the following appearance: 据我所知,一个框架应具有以下外观:

00 00 00 01 XX data ------------- 00 00 00 01 XX数据-------------

where XX is say whether it is a I-,P- or B-frame. 其中XX表示它是I帧,P帧还是B帧。 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. 或更具体地说, type(XX) = 0x0F && XX表示如果是I(类型(XX)= 5?),P(类型(XX)= 7?)或B(类型(XX)= 8?)帧。 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? 这是第一个问题,NALU对于不同的帧应该是多少?

anyway, when i use av_read_frame on the mov file, i get frame that look like this: 无论如何,当我在mov文件上使用av_read_frame时,我得到的帧看起来像这样:

4B = size, 1B = XX and then data. 4B =大小,1B = XX,然后是数据。 (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). 其中i存储帧的文件总是尺寸长,当我在一个16进制软件(否则也当然)看着他们。 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. 并且XX在第一个中始终为65(即,类型(XX)= 5),然后在一帧中为61(即,类型(XX)= 1),然后在一帧中返回到65,依此类推。

i guess that these are frames like: IPPPPPPIPPPPPPPIPPPPP PP .... however then my assumption about the type numbers for the different frame types are false, which is highly likely. 我猜这些帧是这样的:IPPPPPPIPPPPPPPIPPPPP PP ....然而,我对不同帧类型的类型号的假设是错误的,这很有可能。 (any suggestion on reading about this? except the ISO/IEC 14496-10, i don't understand it really). (关于这个的任何建议?除了ISO / IEC 14496-10,我真的不明白)。

I've tried to remove the size and append 00 00 00 01 before the XX byte and the data but without success. 我试图删除大小并在XX字节和数据之前附加00 00 00 01但没有成功。 any tips on how i could modify the frames to be valid H264 encoded frames? 关于如何将帧修改为有效的H264编码帧的任何提示?

First of all, I must recommend a nice tool for understanding H264 streams: http://sourceforge.net/projects/h264bitstream/ 首先,我必须推荐一个很好的工具来理解H264流: 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). 不,要回答您的具体问题,是的,帧通常以65和61开头。通常以67和68开头的特殊NAL单元分别是SPS(序列参数集)和PPS(图片参数集)。

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. 我还建议您尝试使用ffmpeg -i input.mov -vcodec copy output.h264将附件B流(00 00 00 01)正确地作为单个文件获取。

I could not understand exactly, what you are trying to achieve by extracting frames from mov and putting them into test.mov again. 我无法准确理解,你想通过从mov中提取帧并将它们再次放入test.mov来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM