Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with setting and retrieving the value of AVMetadataCommonKeyCreator
    primarykey
    data
    text
    <p>I have a video recording app for the iPhone. I am using <code>AVAssetWriter</code> for writing the recorded video data to a file. I am also interested in embedding custom metadata to the file. For eg: I want to identify my application as the creator of the video.</p> <p>Hence after creating the asset writer, I am adding the creator value using the key <code>AVMetadataCommonKeyCreator</code> to the metadata of the asset writer.</p> <p>Code snippet is as follows:</p> <pre><code>AVAssetWriter *assetWrtr = [[AVAssetWriter alloc] initWithURL:inURL fileType:AVFileTypeQuickTimeMovie error:&amp;error]; self.assetWriter = assetWrtr; [assetWrtr release]; NSArray *existingMetadataArray = self.assetWriter.metadata; NSMutableArray *newMetadataArray = nil; if (existingMetadataArray) { newMetadataArray = [existingMetadataArray mutableCopy]; // To prevent overriding of existing metadata } else { newMetadataArray = [[NSMutableArray alloc] init]; } AVMutableMetadataItem *item = [[AVMutableMetadataItem alloc] init]; item.keySpace = AVMetadataKeySpaceCommon; item.key = AVMetadataCommonKeyCreator; item.value = @"My App"; [newMetadataArray addObject:item]; self.assetWriter.metadata = newMetadataArray; [newMetadataArray release]; [item release]; </code></pre> <p>Once the recording is done, I am trying to read the contents of the file using AVURLAsset.</p> <pre><code>NSURL *outputFileURL = [self.assetWriter outputURL]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:outputFileURL options:nil]; NSArray *keys = [NSArray arrayWithObject:@"commonMetadata"]; [asset loadValuesAsynchronouslyForKeys:keys completionHandler:^(void) { NSError *error = nil; AVKeyValueStatus durationStatus = [asset statusOfValueForKey:@"commonMetadata" error:&amp;error]; switch (durationStatus) { case AVKeyValueStatusLoaded: NSLog(@"AVKeyValueStatusLoaded"); NSLog(@"commonMetadata:%@", [asset commonMetadata]); break; case AVKeyValueStatusFailed: NSLog(@"AVKeyValueStatusFailed"); break; case AVKeyValueStatusCancelled: NSLog(@"AVKeyValueStatusCancelled"); break; } }]; </code></pre> <p>However <code>[asset commonMetadata]</code> does not return any <code>AVMetadataItems</code>. It returns an empty array. I am able to set the values of other meta data objects like <code>AVMetadataCommonKeyTitle</code>, <code>AVMetadataCommonKeyModel</code>, <code>AVMetadataCommonKeySource</code>. These values are retrieved properly. The problem is only with <code>AVMetadataCommonKeyCreator</code>. Please let me know the reason for this behavior. Is it not possible to set app specific value for <code>AVMetadataCommonKeyCreator</code>? What does this key actually represent?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload