1
我試圖使用AVAssetExportSession
來更改文件的元數據,但我嘗試使用的任何元數據似乎都不起作用。當我將一個空數組傳遞給[AVAssetExportSession setMetadata:Array];
時,文件會使用其未經編輯的元數據編寫,但是隻要將AVMetadataItem
放入數組中,就不會將元數據寫入新文件。這裏是我使用的代碼:AVAssetExportSession不導出元數據
//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;
}
}];