1
1
mirror of https://github.com/wader/fq.git synced 2024-12-23 05:13:30 +03:00

mp4: Decode qt minor verison as YYYY.MM description

This commit is contained in:
Mattias Wadman 2023-01-16 12:13:12 +01:00
parent c2795a7c2f
commit f386a5158e
4 changed files with 15 additions and 5 deletions

View File

@ -361,8 +361,18 @@ func decodeBoxIrefEntry(ctx *decodeContext, d *decode.D) {
}
func decodeBoxFtyp(d *decode.D) {
d.FieldUTF8("major_brand", 4)
d.FieldU32("minor_version")
brand := d.FieldUTF8("major_brand", 4)
d.FieldU32("minor_version", scalar.UintFn(func(s scalar.Uint) (scalar.Uint, error) {
switch brand {
case "qt ":
// https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap1/qtff1.html#//apple_ref/doc/uid/TP40000939-CH203-BBCGDDDF
// "For QuickTime movie files, this takes the form of four binary-coded decimal values, indicating the century,
// year, and month of the QuickTime File Format Specification, followed by a binary coded decimal zero. For example,
// for the June 2004 minor version, this field is set to the BCD values 20 04 06 00."
s.Description = fmt.Sprintf("%.4d.%.2d", (s.Actual>>24)&0xff_ff, (s.Actual>>8)&0xff)
}
return s, nil
}))
numBrands := d.BitsLeft() / 8 / 4
var i int64
d.FieldArrayLoop("brands", func() bool { return i < numBrands }, func(d *decode.D) {

View File

@ -6,7 +6,7 @@ $ fq dv in24.mp4
0x000|00 00 00 14 |.... | size: 20 0x0-0x3.7 (4)
0x000| 66 74 79 70 | ftyp | type: "ftyp" (File type and compatibility) 0x4-0x7.7 (4)
0x000| 71 74 20 20 | qt | major_brand: "qt " 0x8-0xb.7 (4)
0x000| 00 00 02 00| ....| minor_version: 512 0xc-0xf.7 (4)
0x000| 00 00 02 00| ....| minor_version: 512 (0000.02) 0xc-0xf.7 (4)
| | | brands[0:1]: 0x10-0x13.7 (4)
0x010|71 74 20 20 |qt | [0]: "qt" brand 0x10-0x13.7 (4)
| | | [1]{}: box 0x14-0x1b.7 (8)

View File

@ -6,7 +6,7 @@ $ fq dv lpcm.mp4
0x000|00 00 00 14 |.... | size: 20 0x0-0x3.7 (4)
0x000| 66 74 79 70 | ftyp | type: "ftyp" (File type and compatibility) 0x4-0x7.7 (4)
0x000| 71 74 20 20 | qt | major_brand: "qt " 0x8-0xb.7 (4)
0x000| 00 00 02 00| ....| minor_version: 512 0xc-0xf.7 (4)
0x000| 00 00 02 00| ....| minor_version: 512 (0000.02) 0xc-0xf.7 (4)
| | | brands[0:1]: 0x10-0x13.7 (4)
0x010|71 74 20 20 |qt | [0]: "qt" brand 0x10-0x13.7 (4)
| | | [1]{}: box 0x14-0x1b.7 (8)

View File

@ -6,7 +6,7 @@ $ fq -d mp4 dv prores_frame.mov
0x0000|00 00 00 14 |.... | size: 20 0x0-0x3.7 (4)
0x0000| 66 74 79 70 | ftyp | type: "ftyp" (File type and compatibility) 0x4-0x7.7 (4)
0x0000| 71 74 20 20 | qt | major_brand: "qt " 0x8-0xb.7 (4)
0x0000| 00 00 02 00| ....| minor_version: 512 0xc-0xf.7 (4)
0x0000| 00 00 02 00| ....| minor_version: 512 (0000.02) 0xc-0xf.7 (4)
| | | brands[0:1]: 0x10-0x13.7 (4)
0x0010|71 74 20 20 |qt | [0]: "qt" brand 0x10-0x13.7 (4)
| | | [1]{}: box 0x14-0x1b.7 (8)