I am trying to parse H.264 frames from a .mov file. I think I came to the conclusion that mov.c from the AVFormat part of FFMPEG is the way to go. But mov.c is ~ 2600 lines next to unregistered code. I am looking for examples of using FFMPEG, especially for parsing the structure of any type of file. it does not matter if it is MPEG4 or Quicktime Movie, as they are very similar in structure.
if there are no existing examples (I cannot find them), maybe someone used it and can give me a couple of lines of code or explain how to get started?
What I'm trying to do: I use AVCaptureSession to capture samples from the camcorder, these samples are then encoded in H264 and written to a file using AVAssetsWriter, AVAssetsWriterInput and AVAssetsWriterInputPixelBufferAdaptor. The reason is that I cannot access the hardware encoding of H264 directly, as Apple will not allow this. What I now need ( I think I'm not sure ) parsing:
" mdat " - atom (movie data may be more than one than I think) from the .mov file. then " vide " - an atom, and then in the form of an atom (there can be more than one video sample). I think there will be several atoms, which I consider to be frames. they will be of type avc1 (this is the type for H264). Please correct me in this, because I am quite sure that I have not yet received all this correctly .
Now my question is how I will parse individual frames. I read the documentation and looked at the iFrameExtractor (which is not very useful as it decodes frames). I think I understood correctly when I should use mov.c from FFMPEG-AVFormat, but I'm not sure.
:
:
init iFrameExtractor, .mov .
:
AVPacket packet;
av_read_frame(pFormatCtx, &packet);
NSData *frame;
if(packet.stream_index == videoStream){
frame = [NSData dataWithBytes:packet.data length:packet.size];
}
videoStream++;
av_free_packet(&packet);
return frame;
i NSOperation, .
EXC_BAD_ACC, - ? . EXC _..., NSData* frame, (, ) . ( EXC_BAD_ACC )