【问题标题】:AVAssetExportSession add meta data after recording endsAVAssetExportSession 在录制结束后添加元数据
【发布时间】:2014-01-27 10:51:09
【问题描述】:

用例如下:使用 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“操作无法完成”用户信息=0x1555f440 {NSLocalizedDescription=操作无法完成,NSUnderlyingError=0x1555c7a0“操作无法完成。(OSStatus错误-12780。)”,NSLocalizedFailureReason=发生未知错误(-12780)}

谁能告诉我我在这里做错了什么?或者有更好的方法吗?

【问题讨论】:

  • 虽然我知道我做错了什么,但我仍然想听听是否有更优化的方法来做到这一点。

标签: avassetexportsession


【解决方案1】:

好吧,我知道我做错了什么。而不是:

NSURL* url = [NSURL URLWithString:outputPath];

我不得不使用:

NSURL* outputUrl = [NSURL fileURLWithPath:outputPath];

Expanation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2016-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多