我正在尝试使用AVAssetExportSession
来更改文件的元数据,但我尝试使用的任何元数据似乎都不起作用。当我将一个空数组传递给[AVAssetExportSession setMetadata:Array];
文件时,它的未编辑元数据会像它应该的那样被写入,但是一旦我将一个AVMetadataItem
放入数组中,就不会将元数据写入新文件。这是我使用的代码:
//NSMutableArray *newArray = [NSMutableArray arrayWithArray:[exportSession metadata]];
AVMutableMetadataItem *addingNew = [[AVMutableMetadataItem alloc] init];
[addingNew setKeySpace:AVMetadataKeySpaceiTunes];
[addingNew setKey:AVMetadataiTunesMetadataKeyUserComment];
[addingNew setValue:[NSString stringWithFormat:@"This is my comment"]];
NSArray *newArray = [NSArray arrayWithObject:addingNew];
NSURL *fileURL = [NSURL fileURLWithPath: outputFile];
[exportSession setMetadata:metaMuteArray];
[exportSession setOutputURL:fileURL];
[exportSession setOutputFileType:AVFileTypeMPEG4];
[exportSession shouldOptimizeForNetworkUse:YES]; //false doesn't work either
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status])
{
case AVAssetExportSessionStatusCompleted:
NSLog(@"Export sucess");
case AVAssetExportSessionStatusFailed:
NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]);
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export canceled");
default:
break;
}
}];