Skip to content

Commit

Permalink
Experiment: Read XMP from MP4 files
Browse files Browse the repository at this point in the history
  • Loading branch information
Numpsy committed Feb 23, 2024
1 parent e81cb19 commit 8887dee
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ATL/AudioData/IO/MP4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,23 @@ private bool readMP4(BinaryReader source, ReadTagParams readTagParams)
}
}

// == XMP
source.BaseStream.Seek(sizeInfo.ID3v2Size, SeekOrigin.Begin);
uint uuidSize = navigateToAtom(source, "uuid");
if (uuidSize > 24)
{
// Read the first 16 bytes, and see if it's the XMP guid
var xmpUuid = new byte[] { 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8, 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac };
var sectionUuid = source.ReadBytes(16);

if (sectionUuid.SequenceEqual(xmpUuid))
{
var xmpBytes = source.ReadBytes((int)uuidSize - 16);
var xmpString = Encoding.UTF8.GetString(xmpBytes);
setXtraField("XMP", xmpString, true);
}
}

return true;
}

Expand Down

0 comments on commit 8887dee

Please sign in to comment.