How to add NSArray in a video with AVMutableMetadataItem?

1k Views Asked by At

I am trying to save video with custom NSArray metadata relevant for my app and trying to retrieve it when the user selects that video from the library. I'm using the AVAssetExportSession function to add metadata.

I used the sample code AVMovieExporter, and I tried to change locationMetadata.value http://developer.apple.com/library/ios/#samplecode/AVMovieExporter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011364

AVMutableMetadataItem *locationMetadata = [[AVMutableMetadataItem alloc] init];
locationMetadata.key = AVMetadataCommonKeyLocation;
locationMetadata.keySpace = AVMetadataKeySpaceCommon;
locationMetadata.locale = self.locale;
//locationMetadata.value = [NSString stringWithFormat:@"%+08.4lf%+09.4lf", self.location.coordinate.latitude, self.location.coordinate.longitude];

locationMetadata.value = [[NSArray alloc] initWithObjects: @"abc", @123,nil];

If I use value as a NSString there is no problem, but if I use a NSArray, it doesn't save the metadata.

Where is the problem?

1

There are 1 best solutions below

1
On

Apple's documentation states:

NSString *const AVMetadataCommonKeyLocation;

I understand that to say the value must be a string, and cannot be an array.