用例是这样的:使用 AVCaptureFileOutput 录制视频并将其保存在临时位置。录制完成后,一些元数据将添加到该视频中,并以新文件名保存在新位置。
记录部分正在处理存储在临时位置的文件。现在我必须重命名它,添加元数据并再次将其保存到不同的位置。
1)我可以在以下位置编辑元数据:
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error;
代理方法?
2)我的第二种方法是使用 AVAssetExportSession 来做到这一点。
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
exportSession.metadata = NEW ARRAY OF METADATA;
NSString* outputPath = [[PLFileManager sharedFileManager] pathForAsset:_newAsset];
NSURL* url = [NSURL URLWithString:outputPath];
exportSession.outputURL = url;
[[NSFileManager defaultManager] removeItemAtURL:url error:nil];
[exportSession exportAsynchronouslyWithCompletionHandler:^(void){
NSLog(@"Exported to [%@] %@", exportSession.outputURL, exportSession.error);
}];
如何使用这种方法我收到以下错误:
导出到 [///var/mobile/Applications/7F9BC121-6F58-436E-8DBE-33D8BC1A4D79/Documents/Temp/final.mov] 错误域=AVFoundationErrorDomain Code=-11800“操作无法完成”UserInfo=0x1555f440 { NSLocalizedDescription=操作无法完成,NSUnderlyingError=0x1555c7a0“操作无法完成。(OSStatus错误-12780。)”,NSLocalizedFailureReason=发生未知错误(-12780)}
有人可以告诉我我在这里做错了什么吗?还是有更好的方法来做到这一点?