Skip to content

Commit

Permalink
mp4: Decode qt minor verison as YYYY.MM description
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Jan 16, 2023
1 parent c2795a7 commit f386a51
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions format/mp4/boxes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion format/mp4/testdata/in24.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion format/mp4/testdata/lpcm.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion format/prores/testdata/prores_frame.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f386a51

Please sign in to comment.