The use case is like this: A video is recorded and saved at a temporary location using AVCaptureFileOutput. After the recording is completed some meta data is to be added to this video and saved with a new filename at a new location.
The recording part is working with the file getting stored at the temporary location. Now I have to rename it, add meta data and save it again to a different location.
1) Can I edit the meta data within the:
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error;
delagate method?
2) My second approach was to use AVAssetExportSession to do this.
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);
}];
How ever with this approach I am getting the following error:
Exported to [///var/mobile/Applications/7F9BC121-6F58-436E-8DBE-33D8BC1A4D79/Documents/Temp/final.mov] Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1555f440 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1555c7a0 "The operation couldn’t be completed. (OSStatus error -12780.)", NSLocalizedFailureReason=An unknown error occurred (-12780)}
Can someone tell me what I am doing wrong here? Or is there a better way to do this?