Convert the .mov file to the .h264 file

ok, it is, I really want to parse frames from the mov file. Get encoded h264 frames. and I managed to do this using ffmpeg, but when I try to make the movie again using ffmpeg -i test* test.mov , I get test00: Invalid data found when processing input , so there is something wrong with the frame structure. as I understand it, the frame should look like this:

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

where XX says whether it is an I-, P- or B-frame. or more specifically, type(XX) = 0x0F && XX says it's me (type (XX) = 5?), P (type (XX) = 7?) or B (type (XX) = 8?). I am not sure about this quantity, I was looking for it, but I did not find good sources. so the question is number one, what number should have NALU for different frames?

anyway, when I use av_read_frame in the mov file, I get a frame that looks like this:

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

the files in which I store frames always have a size when I look at them in hexeditor (otherwise, of course). and XX is always 65 (i.e. type (XX) = 5) in the first, and then 61 (i.e. type (XX) = 1) for a pair of frames, and then back to 65 for one frame, etc. .

I assume that these are frames such as: I PPPPPPPPPPPPPPPPPPPPPP PPPPPPP P .... however, then my assumption about type numbers for different types of frames is false, which is very likely. (any reading suggestion about this, with the exception of ISO / IEC 14496-10, I really don't understand).

I tried to remove the size and add 00 00 00 01 to XX bytes and data, but to no avail. any tips on how I can change frames to be valid H264 encoded frames?

+7
source share
1 answer

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

No, to answer your specific question, yes, frames usually start at 65 and 61. Special NAL modules that usually start at 67 and 68 are SPS (set of sequence parameters) and PPS (set of image parameters), respectively.

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

I couldn’t understand exactly what you were trying to achieve by extracting frames from mov and putting them again in test.mov.

+5
source

All Articles