Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there multiple timescale specified in a MP4/AVC container file?

I am currently parsing a MPEG-DASH stream initialization segment (generated by FFMPEG) and I noticed that the timescale is specified at multiple different places in my file:

  • In the movie header box (mvhd): 1000
  • In the media header box of my video track (mdhd): 15360
  • In the AVC Configuration box (avcC) more precisely in the VUI section of the sequence parameter set NAL unit: 60

Why is it specified in so many different places? Why do they have different values? Is there a hierarchy in these value? For example does 60 overrides 15360 and 15360 overrides 1000?

Here's the command I used to generate the file I am looking at:

ffmpeg -f v4l2 -pixel_format yuyv422 -vcodec rawvideo -framerate 30 -video_size 640x360 -i /dev/video0 \
        -f dash -remove_at_exit false -use_template true -use_timeline true -streaming true -window_size 5 -extra_window_size 5 -seg_duration 5 -vcodec libx264 -b:v 1M -maxrate 1M -bufsize 2M  -pix_fmt yuv420p -r 30 -s 640x360 -aspect 16:9 /var/www/html/media/live.mpd
like image 580
Lexx32117 Avatar asked Nov 07 '25 11:11

Lexx32117


1 Answers

In the movie header box (mvhd): 1000

This is the movie timescale. It's used in places such as the duration field of edit list entries.

In the media header box of my video track (mdhd): 15360

This is the track timescale. This is used for the sample timestamp field in edit list entries and the duration field in the stts, stss, ctts boxes. ffmpeg (& other apps) will generate timestamps based on this timescale.

In the AVC Configuration box (avcC) more precisely in the VUI section of the sequence parameter set NAL unit: 60

That's the encoder time-base. The encoder uses timestamps denominated in this time-base for ratecontrol purposes. This is the tbc value that ffmpeg shows. This is internal to the bitstream and the container pays no heed to it.

like image 148
Gyan Avatar answered Nov 10 '25 10:11

Gyan