1
1
mirror of https://github.com/wader/fq.git synced 2024-09-11 12:05:39 +03:00

mp4: Turns out for qt brand hdlr component name might be zero bytes

From QuickTime File Format specification:
A (counted) string that specifies the name of the component—that is, the media handler used
when this media was created. This field may contain a zero-length (empty) string.
This commit is contained in:
Mattias Wadman 2024-03-19 17:06:21 +01:00
parent 853f78decc
commit ed3a126f0a
3 changed files with 29 additions and 1 deletions

View File

@ -533,7 +533,12 @@ func decodeBox(ctx *decodeContext, d *decode.D, typ string) {
switch majorBrand {
case "qt":
// qt brand seems to use length prefixed strings
d.FieldUTF8ShortStringFixedLen("component_name", int(d.BitsLeft()/8))
// From QuickTime File Format specification:
// > A (counted) string that specifies the name of the component—that is, the media handler used
// > when this media was created. This field may contain a zero-length (empty) string.
if d.BitsLeft() > 0 {
d.FieldUTF8ShortStringFixedLen("component_name", int(d.BitsLeft()/8))
}
default:
d.FieldUTF8NullFixedLen("component_name", int(d.BitsLeft()/8))
}

Binary file not shown.

View File

@ -0,0 +1,23 @@
$ fq dv qt_brand_zero_byte_hdlr_component_name.mp4
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: qt_brand_zero_byte_hdlr_component_name.mp4 (mp4) 0x0-0x40 (64)
| | | boxes[0:2]: 0x0-0x40 (64)
| | | [0]{}: box 0x0-0x20 (32)
0x00|00 00 00 20 |... | size: 32 0x0-0x4 (4)
0x00| 66 74 79 70 | ftyp | type: "ftyp" (File type and compatibility) 0x4-0x8 (4)
0x00| 71 74 20 20 | qt | major_brand: "qt" 0x8-0xc (4)
0x00| 20 05 03 00| ...| minor_version: 537199360 (0032.03) 0xc-0x10 (4)
| | | brands[0:4]: 0x10-0x20 (16)
0x10|71 74 20 20 |qt | [0]: "qt" brand 0x10-0x14 (4)
0x10| 00 00 00 00 | .... | [1]: "\x00\x00\x00\x00" brand 0x14-0x18 (4)
0x10| 00 00 00 00 | .... | [2]: "\x00\x00\x00\x00" brand 0x18-0x1c (4)
0x10| 00 00 00 00| ....| [3]: "\x00\x00\x00\x00" brand 0x1c-0x20 (4)
| | | [1]{}: box 0x20-0x40 (32)
0x20|00 00 00 20 |... | size: 32 0x20-0x24 (4)
0x20| 68 64 6c 72 | hdlr | type: "hdlr" (Handler, declares the media (handler) type) 0x24-0x28 (4)
0x20| 00 | . | version: 0 0x28-0x29 (1)
0x20| 00 00 00 | ... | flags: 0 0x29-0x2c (3)
0x20| 00 00 00 00| ....| component_type: "" 0x2c-0x30 (4)
0x30|6d 64 74 61 |mdta | component_subtype: "mdta" (Metadata Tags) 0x30-0x34 (4)
0x30| 00 00 00 00 | .... | component_manufacturer: "" 0x34-0x38 (4)
0x30| 00 00 00 00 | .... | component_flags: 0 0x38-0x3c (4)
0x30| 00 00 00 00| ....| component_flags_mask: 0 0x3c-0x40 (4)