1

I am writing a little video-editing app on iOS. I followed the most rated answer in this question to use AVAssetwriter, but the writing failed in the end. When I got into the complete callback in

[videoWriter finishWritingWithCompletionHandler:^(){}];

I got this error from the videoWriter.error every time.

[0] (null)  "NSUnderlyingError" : domain: "NSOSStatusErrorDomain" - code: 18446744073709539204  
[1] (null)  "NSLocalizedRecoverySuggestion" : "Try saving again."   
[2] (null)  "NSLocalizedDescription" : "Cannot Save"    

The URL I tried to save the image is built by

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *filename = @"processedVideo.mp4";
NSString *filenameFull = [documentsDir stringByAppendingPathComponent:filename];
NSURL *videoOutURL = [NSURL fileURLWithPath:filenameFull];

So it is like

file:///var/mobile/Containers/Data/Application/FA2BF494-9093-4034-8E6F-0FC177C9F2E3/Documents/processedVideo.mp4

Any suggestions on what did I get wrong?

Community
  • 1
  • 1
Jason M
  • 411
  • 5
  • 19
  • 1
    It turned out that the issue was manipulating the frame buffers mistakenly . When generating and filling each frame buffer, I accidentally accessed memory beyond boundary but it issued no error until finishing and compressing begin. – Jason M May 03 '17 at 00:16

1 Answers1

2

if already a file exist in saving directory then asset writer give writing error. first check if the if there is any file exists . you can remove previous existing file by this.

BOOL success = [fileManager removeItemAtPath: filenameFull error:&error];

or you can write file with different file name . hope it will works

Return Zero
  • 424
  • 4
  • 15