Skip to content

Commit

Permalink
mp4: Decode tkhd flags
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Jan 13, 2023
1 parent 162cb40 commit 3555dc6
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 22 deletions.
8 changes: 7 additions & 1 deletion format/mp4/boxes.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,13 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
case "tkhd":
var trackID int
version := d.FieldU8("version")
d.FieldU24("flags")
d.FieldStruct("flags", func(d *decode.D) {
d.FieldU20("unused")
d.FieldBool("size_is_aspect_ratio")
d.FieldBool("in_preview")
d.FieldBool("in_movie")
d.FieldBool("enabled")
})
switch version {
case 0:
d.FieldU32("creation_time", uintActualQuicktimeEpoch)
Expand Down
7 changes: 6 additions & 1 deletion format/mp4/testdata/aac.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ $ fq -d mp4 dv aac.mp4
0x310|00 5c |.\ |
0x310| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0x312-0x315.7 (4)
0x310| 00 | . | version: 0 0x316-0x316.7 (1)
0x310| 00 00 03 | ... | flags: 3 0x317-0x319.7 (3)
| | | flags{}: 0x317-0x319.7 (3)
0x310| 00 00 03 | ... | unused: 0 0x317-0x319.3 (2.4)
0x310| 03 | . | size_is_aspect_ratio: false 0x319.4-0x319.4 (0.1)
0x310| 03 | . | in_preview: false 0x319.5-0x319.5 (0.1)
0x310| 03 | . | in_movie: true 0x319.6-0x319.6 (0.1)
0x310| 03 | . | enabled: true 0x319.7-0x319.7 (0.1)
0x310| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x31a-0x31d.7 (4)
0x310| 00 00| ..| modification_time: 0 (1904-01-04T00:00:00Z) 0x31e-0x321.7 (4)
0x320|00 00 |.. |
Expand Down
7 changes: 6 additions & 1 deletion format/mp4/testdata/av1.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ $ fq -d mp4 dv av1.mp4
0x1230| 00 00 00 5c| ...\| size: 92 0x123c-0x123f.7 (4)
0x1240|74 6b 68 64 |tkhd | type: "tkhd" (Track header, overall information about the track) 0x1240-0x1243.7 (4)
0x1240| 00 | . | version: 0 0x1244-0x1244.7 (1)
0x1240| 00 00 03 | ... | flags: 3 0x1245-0x1247.7 (3)
| | | flags{}: 0x1245-0x1247.7 (3)
0x1240| 00 00 03 | ... | unused: 0 0x1245-0x1247.3 (2.4)
0x1240| 03 | . | size_is_aspect_ratio: false 0x1247.4-0x1247.4 (0.1)
0x1240| 03 | . | in_preview: false 0x1247.5-0x1247.5 (0.1)
0x1240| 03 | . | in_movie: true 0x1247.6-0x1247.6 (0.1)
0x1240| 03 | . | enabled: true 0x1247.7-0x1247.7 (0.1)
0x1240| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x1248-0x124b.7 (4)
0x1240| 00 00 00 00| ....| modification_time: 0 (1904-01-04T00:00:00Z) 0x124c-0x124f.7 (4)
0x1250|00 00 00 01 |.... | track_id: 1 0x1250-0x1253.7 (4)
Expand Down
7 changes: 6 additions & 1 deletion format/mp4/testdata/avc.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ $ fq -d mp4 dv avc.mp4
0x00e00|5c |\ |
0x00e00| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0xe01-0xe04.7 (4)
0x00e00| 00 | . | version: 0 0xe05-0xe05.7 (1)
0x00e00| 00 00 03 | ... | flags: 3 0xe06-0xe08.7 (3)
| | | flags{}: 0xe06-0xe08.7 (3)
0x00e00| 00 00 03 | ... | unused: 0 0xe06-0xe08.3 (2.4)
0x00e00| 03 | . | size_is_aspect_ratio: false 0xe08.4-0xe08.4 (0.1)
0x00e00| 03 | . | in_preview: false 0xe08.5-0xe08.5 (0.1)
0x00e00| 03 | . | in_movie: true 0xe08.6-0xe08.6 (0.1)
0x00e00| 03 | . | enabled: true 0xe08.7-0xe08.7 (0.1)
0x00e00| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0xe09-0xe0c.7 (4)
0x00e00| 00 00 00| ...| modification_time: 0 (1904-01-04T00:00:00Z) 0xe0d-0xe10.7 (4)
0x00e10|00 |. |
Expand Down
14 changes: 12 additions & 2 deletions format/mp4/testdata/dash.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ $ fq -d mp4 dv dash_audio_init.mp4
0x120| 00 00 00 5c | ...\ | size: 92 0x123-0x126.7 (4)
0x120| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0x127-0x12a.7 (4)
0x120| 00 | . | version: 0 0x12b-0x12b.7 (1)
0x120| 00 00 07 | ... | flags: 7 0x12c-0x12e.7 (3)
| | | flags{}: 0x12c-0x12e.7 (3)
0x120| 00 00 07 | ... | unused: 0 0x12c-0x12e.3 (2.4)
0x120| 07 | . | size_is_aspect_ratio: false 0x12e.4-0x12e.4 (0.1)
0x120| 07 | . | in_preview: true 0x12e.5-0x12e.5 (0.1)
0x120| 07 | . | in_movie: true 0x12e.6-0x12e.6 (0.1)
0x120| 07 | . | enabled: true 0x12e.7-0x12e.7 (0.1)
0x120| dd| .| creation_time: 3713521298 (2021-09-06T13:41:38Z) 0x12f-0x132.7 (4)
0x130|57 d6 92 |W.. |
0x130| dd 57 d6 92 | .W.. | modification_time: 3713521298 (2021-09-06T13:41:38Z) 0x133-0x136.7 (4)
Expand Down Expand Up @@ -612,7 +617,12 @@ $ fq -d mp4 dv dash_video_init.mp4
0x0120| 00 00 00 5c | ...\ | size: 92 0x127-0x12a.7 (4)
0x0120| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0x12b-0x12e.7 (4)
0x0120| 00| .| version: 0 0x12f-0x12f.7 (1)
0x0130|00 00 07 |... | flags: 7 0x130-0x132.7 (3)
| | | flags{}: 0x130-0x132.7 (3)
0x0130|00 00 07 |... | unused: 0 0x130-0x132.3 (2.4)
0x0130| 07 | . | size_is_aspect_ratio: false 0x132.4-0x132.4 (0.1)
0x0130| 07 | . | in_preview: true 0x132.5-0x132.5 (0.1)
0x0130| 07 | . | in_movie: true 0x132.6-0x132.6 (0.1)
0x0130| 07 | . | enabled: true 0x132.7-0x132.7 (0.1)
0x0130| dd 57 d6 ae | .W.. | creation_time: 3713521326 (2021-09-06T13:42:06Z) 0x133-0x136.7 (4)
0x0130| dd 57 d6 ae | .W.. | modification_time: 3713521326 (2021-09-06T13:42:06Z) 0x137-0x13a.7 (4)
0x0130| 00 00 00 01 | .... | track_id: 1 0x13b-0x13e.7 (4)
Expand Down
7 changes: 6 additions & 1 deletion format/mp4/testdata/flac.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ $ fq -d mp4 dv flac.mp4
0x300| 00 00 00 5c | ...\ | size: 92 0x306-0x309.7 (4)
0x300| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0x30a-0x30d.7 (4)
0x300| 00 | . | version: 0 0x30e-0x30e.7 (1)
0x300| 00| .| flags: 3 0x30f-0x311.7 (3)
| | | flags{}: 0x30f-0x311.7 (3)
0x300| 00| .| unused: 0 0x30f-0x311.3 (2.4)
0x310|00 03 |.. |
0x310| 03 | . | size_is_aspect_ratio: false 0x311.4-0x311.4 (0.1)
0x310| 03 | . | in_preview: false 0x311.5-0x311.5 (0.1)
0x310| 03 | . | in_movie: true 0x311.6-0x311.6 (0.1)
0x310| 03 | . | enabled: true 0x311.7-0x311.7 (0.1)
0x310| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x312-0x315.7 (4)
0x310| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0x316-0x319.7 (4)
0x310| 00 00 00 01 | .... | track_id: 1 0x31a-0x31d.7 (4)
Expand Down
14 changes: 12 additions & 2 deletions format/mp4/testdata/fragmented.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ $ fq -d mp4 dv fragmented.mp4
0x000a0|00 00 00 5c |...\ | size: 92 0xa0-0xa3.7 (4)
0x000a0| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0xa4-0xa7.7 (4)
0x000a0| 00 | . | version: 0 0xa8-0xa8.7 (1)
0x000a0| 00 00 03 | ... | flags: 3 0xa9-0xab.7 (3)
| | | flags{}: 0xa9-0xab.7 (3)
0x000a0| 00 00 03 | ... | unused: 0 0xa9-0xab.3 (2.4)
0x000a0| 03 | . | size_is_aspect_ratio: false 0xab.4-0xab.4 (0.1)
0x000a0| 03 | . | in_preview: false 0xab.5-0xab.5 (0.1)
0x000a0| 03 | . | in_movie: true 0xab.6-0xab.6 (0.1)
0x000a0| 03 | . | enabled: true 0xab.7-0xab.7 (0.1)
0x000a0| 00 00 00 00| ....| creation_time: 0 (1904-01-04T00:00:00Z) 0xac-0xaf.7 (4)
0x000b0|00 00 00 00 |.... | modification_time: 0 (1904-01-04T00:00:00Z) 0xb0-0xb3.7 (4)
0x000b0| 00 00 00 01 | .... | track_id: 1 0xb4-0xb7.7 (4)
Expand Down Expand Up @@ -314,7 +319,12 @@ $ fq -d mp4 dv fragmented.mp4
0x00280| 00 00 00 5c| ...\| size: 92 0x28c-0x28f.7 (4)
0x00290|74 6b 68 64 |tkhd | type: "tkhd" (Track header, overall information about the track) 0x290-0x293.7 (4)
0x00290| 00 | . | version: 0 0x294-0x294.7 (1)
0x00290| 00 00 03 | ... | flags: 3 0x295-0x297.7 (3)
| | | flags{}: 0x295-0x297.7 (3)
0x00290| 00 00 03 | ... | unused: 0 0x295-0x297.3 (2.4)
0x00290| 03 | . | size_is_aspect_ratio: false 0x297.4-0x297.4 (0.1)
0x00290| 03 | . | in_preview: false 0x297.5-0x297.5 (0.1)
0x00290| 03 | . | in_movie: true 0x297.6-0x297.6 (0.1)
0x00290| 03 | . | enabled: true 0x297.7-0x297.7 (0.1)
0x00290| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x298-0x29b.7 (4)
0x00290| 00 00 00 00| ....| modification_time: 0 (1904-01-04T00:00:00Z) 0x29c-0x29f.7 (4)
0x002a0|00 00 00 02 |.... | track_id: 2 0x2a0-0x2a3.7 (4)
Expand Down
7 changes: 6 additions & 1 deletion format/mp4/testdata/hevc.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ $ fq -d mp4 dv hevc.mp4
0x0900|5c |\ |
0x0900| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0x901-0x904.7 (4)
0x0900| 00 | . | version: 0 0x905-0x905.7 (1)
0x0900| 00 00 03 | ... | flags: 3 0x906-0x908.7 (3)
| | | flags{}: 0x906-0x908.7 (3)
0x0900| 00 00 03 | ... | unused: 0 0x906-0x908.3 (2.4)
0x0900| 03 | . | size_is_aspect_ratio: false 0x908.4-0x908.4 (0.1)
0x0900| 03 | . | in_preview: false 0x908.5-0x908.5 (0.1)
0x0900| 03 | . | in_movie: true 0x908.6-0x908.6 (0.1)
0x0900| 03 | . | enabled: true 0x908.7-0x908.7 (0.1)
0x0900| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x909-0x90c.7 (4)
0x0900| 00 00 00| ...| modification_time: 0 (1904-01-04T00:00:00Z) 0x90d-0x910.7 (4)
0x0910|00 |. |
Expand Down
7 changes: 6 additions & 1 deletion format/mp4/testdata/in24.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ $ fq dv in24.mp4
0x1a0| 00 00 00 5c | ...\ | size: 92 0x1a8-0x1ab.7 (4)
0x1a0| 74 6b 68 64| tkhd| type: "tkhd" (Track header, overall information about the track) 0x1ac-0x1af.7 (4)
0x1b0|00 |. | version: 0 0x1b0-0x1b0.7 (1)
0x1b0| 00 00 03 | ... | flags: 3 0x1b1-0x1b3.7 (3)
| | | flags{}: 0x1b1-0x1b3.7 (3)
0x1b0| 00 00 03 | ... | unused: 0 0x1b1-0x1b3.3 (2.4)
0x1b0| 03 | . | size_is_aspect_ratio: false 0x1b3.4-0x1b3.4 (0.1)
0x1b0| 03 | . | in_preview: false 0x1b3.5-0x1b3.5 (0.1)
0x1b0| 03 | . | in_movie: true 0x1b3.6-0x1b3.6 (0.1)
0x1b0| 03 | . | enabled: true 0x1b3.7-0x1b3.7 (0.1)
0x1b0| 00 00 00 00 | .... | creation_time: 0 (1904-01-04T00:00:00Z) 0x1b4-0x1b7.7 (4)
0x1b0| 00 00 00 00 | .... | modification_time: 0 (1904-01-04T00:00:00Z) 0x1b8-0x1bb.7 (4)
0x1b0| 00 00 00 01| ....| track_id: 1 0x1bc-0x1bf.7 (4)
Expand Down
7 changes: 6 additions & 1 deletion format/mp4/testdata/lpcm.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ $ fq dv lpcm.mp4
0x2e0|00 00 00 5c |...\ | size: 92 0x2e0-0x2e3.7 (4)
0x2e0| 74 6b 68 64 | tkhd | type: "tkhd" (Track header, overall information about the track) 0x2e4-0x2e7.7 (4)
0x2e0| 00 | . | version: 0 0x2e8-0x2e8.7 (1)
0x2e0| 00 00 03 | ... | flags: 3 0x2e9-0x2eb.7 (3)
| | | flags{}: 0x2e9-0x2eb.7 (3)
0x2e0| 00 00 03 | ... | unused: 0 0x2e9-0x2eb.3 (2.4)
0x2e0| 03 | . | size_is_aspect_ratio: false 0x2eb.4-0x2eb.4 (0.1)
0x2e0| 03 | . | in_preview: false 0x2eb.5-0x2eb.5 (0.1)
0x2e0| 03 | . | in_movie: true 0x2eb.6-0x2eb.6 (0.1)
0x2e0| 03 | . | enabled: true 0x2eb.7-0x2eb.7 (0.1)
0x2e0| 00 00 00 00| ....| creation_time: 0 (1904-01-04T00:00:00Z) 0x2ec-0x2ef.7 (4)
0x2f0|00 00 00 00 |.... | modification_time: 0 (1904-01-04T00:00:00Z) 0x2f0-0x2f3.7 (4)
0x2f0| 00 00 00 01 | .... | track_id: 1 0x2f4-0x2f7.7 (4)
Expand Down

0 comments on commit 3555dc6

Please sign in to comment.