You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 line
919 B

  1. ref https://stackoverflow.com/questions/53992918/about-fmp4-encoding-how-to-fill-the-mdat-box-wit-h264-frame?r=SearchResults
  2. H.264 can be in different stream formats. One is called "Annex B" the other one is MP4. In "Annex B" your NAL units are prefix with start codes 00 00 00 01 or 00 00 01. In MP4 your NAL units are prefixed with the size in bytes.
  3. I assume your encoder emits "Annex B".
  4. Remove the start code (00) 00 00 01
  5. Prefix your NAL units with the size (typically 4 bytes)
  6. Filter out AUD/SPS/PPS NAL units from your stream
  7. Write you converted NAL units into the MDAT box
  8. Create an AVC Configuration Box ('avcC') based on your SPS, PPS and the length size
  9. Store your avcC box in moov->trak->mdia->minf->stbl->avc1->avcC
  10. While you are writing your samples into mdat - keep track of sizes, offsets and frame types to create the correct stts, stss, stsc, stsz and stco boxes.