Search code examples
quicktime

Quicktime metadata APIs and iTunes


I'm trying to set some metadata in a .mov file with the quicktime metadata APIs and have it show up in iTunes. I've got it working for most of the properties, but I can't get the description field to populate. Here is the code I'm using (shortened to only show what I think is the relevant portion).

const char* cString = ([@"HELLO WORLD" cStringUsingEncoding:NSMacOSRomanStringEncoding]);

QTMovie* qtMovie = [[QTMovie alloc] initWithFile:filename error:&error];
Movie movie = [qtMovie quickTimeMovie];

QTMetaDataRef metaDataRef = NULL;
OSStatus err = noErr;
err = QTCopyMovieMetaData(movie, &metaDataRef);

QTMetaDataItem outItem;
QTMetaDataAddItem(metaDataRef,
                  kQTMetaDataStorageFormatiTunes, 
                  kQTMetaDataKeyFormatCommon,
                  (const UInt8 *)&key,
                  sizeof(key),
                  (const UInt8 *)cString,
                  strlen(cString),
                  kQTMetaDataTypeUTF8,
                  &outItem);

I found the following link, stating that for the information and description properties, I should be using kQTMetaDataStorageFormatQuicktime, but that doesn't seem to make any difference. Has anyone else had any success getting the description column to populate when importing metadata into iTunes videos?

http://lists.apple.com/archives/quicktime-api/2006/May/msg00115.html


Solution

  • Figured it out finally with the help of this post and some deep debugging into the contents of my tagged media.

    Retrieving the key name on AVMetadataItem for an AVAsset in iOS

    I set the data format to kQTMetaDataStorageFormatiTunes and the key format to kQTMetaDataKeyFormatiTunesShortForm. And then the tags I use are the encoded id3 tags like in the post above. The common keys (kQTMetaDataCommonKeyArtist, kQTMetaDataCommonKeyComment) will generally not work if your goal is to view the data in iTunes. It seems a couple of them still do work, but in general they don't map over properly to their id3 counterparts.