MP4 is a suitable file format for streaming media storage. However, saving H.264 video in MP4 file format is a little bit tricky than normal MPEG4 video.
Sometimes you may find that some players based on ffdshow can play H.264 in MP4 while VLC doesn't. That is because the sample data(an NALU actually) is not written correctly.
Usually an NALU is prefixed by the start code 0x00000001. To write it as a sample in MP4 file format, just replace the start code with size of the NALU(without 4-byte start code) in big endian. You also need to specify how many bytes of the size value requires. Take libmp4v2 for example, the last parameter in MP4AddH264VideoTrack(.., uint8_t sampleLenFieldSizeMinusOne) indicate the number of byes minus one.
No comments:
Post a Comment