Skip to content

Commit fb43300

Browse files
add support for apple live-photo mov file refer #344 (#426)
Add support for apple live-photo mov. Fixes #344 Co-authored-by: Drew Noakes <[email protected]>
1 parent 4e5042d commit fb43300

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

MetadataExtractor/Formats/QuickTime/QuickTimeTypeChecker.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,33 @@ internal sealed class QuickTimeTypeChecker : ITypeChecker
6363

6464
private static ReadOnlySpan<byte> FtypBytes => "ftyp"u8;
6565

66-
public int ByteCount => 12;
66+
public int ByteCount => 16;
6767

6868
public Util.FileType CheckType(byte[] bytes)
6969
{
70-
return bytes.AsSpan(4, 4).SequenceEqual(FtypBytes)
71-
? _ftypTrie.Find(bytes.AsSpan(8, 4))
72-
: Util.FileType.Unknown;
70+
// for standard apple quicktime format
71+
// 00000000: 0000 0014 6674 7970 7174 2020 0000 0000 ....ftypqt ....
72+
// 00000010: 7174 2020 0000 0008 7769 6465 003e f32a qt ....wide.>.*
73+
// 00000020: 6d64 6174 cefe f2fe 09ff 09ff 0dff 31ff mdat..........1.
74+
if (bytes.AsSpan(4, 4).SequenceEqual(FtypBytes))
75+
{
76+
return _ftypTrie.Find(bytes.AsSpan(8, 4));
77+
}
78+
79+
// for live photo which is export from native protocols with afcclient/afcservice
80+
// example 1
81+
// 00000000: 0000 0008 7769 6465 0033 a50e 6d64 6174 ....wide.3..mdat
82+
// 00000010: 0000 001f 4e01 051a 4756 4adc 5c4c 433f ....N...GVJ.\LC?
83+
// 00000020: 94ef c511 3cd1 43a8 03ee 1111 ee02 00c3 ....<.C.........
84+
// example 2
85+
// 00000000: 0000 0008 7769 6465 004f 854d 6d64 6174 ....wide.O.Mmdat
86+
// 00000010: 0000 002a 4e01 0523 4756 4adc 5c4c 433f ...*N..#GVJ.\LC?
87+
// 00000020: 94ef c511 3cd1 43a8 0000 0300 0003 0000 ....<.C.........
88+
if (bytes.AsSpan(4, 4).SequenceEqual("wide"u8) && bytes.AsSpan(12, 4).SequenceEqual("mdat"u8))
89+
{
90+
return Util.FileType.QuickTime;
91+
}
92+
return Util.FileType.Unknown;
7393
}
7494
}
7595
}

0 commit comments

Comments
 (0)