How to read Mdat atoms of a mp4 video?

Viewed 518

I am trying to parse a mp4 and able to do parse moov but not sure how to use moov information to parse mdat.

My goal is to get the track info like metadata and if possible frames from mdat as it contains the video and audio data.

currently following QuickTime File Format Specification

Tried with Sample-to-Chunk Atoms but all my stsc (20 bytes) looks like this:

[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0]
[0 0 0 1]
[0 0 0 1 0 0 0 1]
[0 0 0 1]
    fmt.Println(binary.BigEndian.Uint32(buf[0:4])) //4
    fmt.Println(binary.BigEndian.Uint32(buf[4:8])) //4
    fmt.Println(binary.BigEndian.Uint32(buf[8:16])) //8
    fmt.Println(binary.BigEndian.Uint32(buf[16:20])) //4

Don't know currently how to approach and parse mdat atoms.

Any help would be appreciated!

1 Answers

the mp4 specification is ISO/IEC 14496-12 which is more definitive than the qt one.

If you want to understand how the sample tables reference individual frames you could look at my project here https://github.com/essential61/mp4analyser

Related