How the player parses the MP4 file and plays the tracks in it?

1k Views Asked by At

I am trying to understand from where the MP4 parsing begins in Player. I mean that I needs the dataflow from where the parsing begins and how the mvhd, tkhd, mdat and metadata are utilised

Thank You

1

There are 1 best solutions below

0
On

See also: MP4 Atom Parsing - where to configure time…?

The parsing happens within moov (mvhd,tkhd, etc).

There is no data flow, you parse the neccessarymoov data to extract a frame (audio or video), once extracted they are passed to the relevant a/v decoder (eg: H264/H265/aac/mp3) to decode a picture or sound.

For a keyframe you look at STSS (SS = sync sample) to find a keyframe's bytes location within mdatsection. Then use STSZ atom to know how much size of bytes for this keyframe. Send those bytes to an H264 decoder to see a frame/image. If you need other info like timecode of this frame then you check STTS (Time-To-Sample) atom for the numbers.