I'm trying to get h.264 NAL units from a MOV file on the iPhone, in order to RTP h.264 video from the iPhone camera to a server.
Apple's API does not allow direct access to the encoded bitstream from the camera output, so I can only access the MOV file, while it's being written.
I've parsed the MOV file into Atoms, according to Apple's MOV structure reference but now i need to extract the NAL units from the mdat atom in order to pack it to RTP and stream it.
I'd be glad for some help here because i can't find documentation about the mdat structure. Thanks!
The mdat atom is a big blob of data that makes no sense on its own. To understand its contents, one must first parse the moov atom. You said that you decomposed the MOV files into atoms-- did you dig deeper than just moov, mdat, ftyp, and a few other top-level atoms? You have to parse the moov atom (lots of atoms in there) to get the data you need (extra codec data attached to the H.264 stsd atom which is combined with data from the H.264 chunks, which are indexed by the stco or co64 atoms).
Or use a library that already does all the tedious work for you.
来源:https://stackoverflow.com/questions/11717538/parsing-h-264-nal-units-from-a-quicktime-mov-file