I’m trying to attach some XMP metadata to a QuickTime video I'm exporting using AVAssetExportSession
.
AVFoundation does support writing metadata (AVMetadataItem
) and I’ve managed to export simple values which can subsequently be examined using exiftool:
AVMutableMetadataItem *item = [AVMutableMetadataItem metadataItem];
item.identifier = [AVMetadataItem identifierForKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
item.value = @"My Title";
exportSession.metadata = @[item];
But I’m having trouble configuring my AVMetadataItem
’s to correctly encode XMP. According to the Adobe XMP spec, XMP in QuickTime videos should be under the moov
/ udta
/ XMP_
atoms but I can’t see a way to make hierarchical metadata using the AVFoundation API, or any key space that corresponds to this part of the metadata.
I also need to write XMP metadata to images, and Image I/O does have direct support for this (CGImageMetadataCreateFromXMPData
), but I can't find anything equivalent in AVFoundation.
If it's not possible using AVFoundation (or similar), I'll probably look at integrating XMP-Toolkit-SDK but this feels like a clunky solution when AVFoundation almost seems to do what I need.