mp4 文件 mdhd 解析

Box Type:    ‘mdhd’

Container: Media Box (‘mdia’) Mandatory: Yes

Quantity: Exactly one

The media header declares overall information that is media‐independent, and relevant to characteristics of the media in a track.

aligned(8) class MediaHeaderBox extends FullBox(‘mdhd’, version, 0) { 
    if (version==1) { 
        unsigned int(64) creation_time; 
        unsigned int(64) modification_time; 
        unsigned int(32) timescale; 
        unsigned int(64) duration; 
    } else { // version==0 
        unsigned int(32) creation_time; 
        unsigned int(32) modification_time; 
        unsigned int(32) timescale; 
        unsigned int(32) duration; 
    } 
    bit(1) pad = 0; 
    unsigned int(5)[3] language; // ISO-639-2/T language code 
    unsigned int(16) pre_defined = 0; 
} 

version is an integer that specifies the version of this box (0 or 1)

creation_time is an integer that declares the creation time of the media in this track (in seconds since midnight, Jan. 1, 1904, in UTC time).

modification_time is an integer that declares the most recent time the media in this track was modified (in seconds since midnight, Jan. 1, 1904, in UTC time).

timescale is an integer that specifies the timescale for this media; this is the number of time units that pass in one second. For example, a time coordinate system that measures time in sixtieths of a second has a time scale of 60.

duration is an integer that declares the duration of this media (in the scale of the timescale). If the duration cannot be determined then duration is set to all 1s.

language declares the language code for this media. See ISO 639‐2/T for the set of three character codes. Each character is packed as the difference between its ASCII value and 0x60. Since the code is confined to being three lower‐case letters, these values are strictly positive.

ffffff_with_tow_audio.mp4.tar

00000640: 00 01 a0 6d 64 69 61 00 00 00 20 6d 64 68 64 00 …mdia… mdhd.
00000650: 00 00 00 00 00 00 00 00 00 00 00 00 01 5f 90 00 …………._..
00000660: 00 0e 10 55 c4 00 00 00 00 00 2d 68 64 6c 72 00 …U……-hdlr.
00000670: 00 00 00 00 00 00 00 76 69 64 65 00 00 00 00 00 …….vide…..
00000680: 00 00 00 00 00 00 00 56 69 64 65 6f 48 61 6e 64 …….VideoHand

size 00 00 00 20

type 6d 64 68 64

flags 00

version 00 00 00

createtime 32 00 00 00 00

modification_time 32 00 00 00 00

timescale 32 00 01 5f 90 == 90000

duration 32 00 00 0e 10 ==  3600

language 55 c4= 0 101 0101 1100 0100
每5位一个字符,一种3个字符,10101 01110 00100 == 0x15 0x0E 0x04  全部加0x60 == 0x75 0x6E 0x64 == und

00000860: 00 00 00 00 01 00 00 00 00 01 34 6d 64 69 61 00 ……….4mdia.
00000870: 00 00 20 6d 64 68 64 00 00 00 00 00 00 00 00 00 .. mdhd………
00000880: 00 00 00 00 00 bb 80 00 00 06 00 55 c4 00 00 00 ………..U….
00000890: 00 00 2d 68 64 6c 72 00 00 00 00 00 00 00 00 73 ..-hdlr……..s
000008a0: 6f 75 6e 00 00 00 00 00 00 00 00 00 00 00 00 53 oun…………S