I have been struggling with this problem for over a week. I hope someone sees what I'm doing wrong. I am attempting to use the finishWritingWithCompletionHandler: method since the finishWriting method is now deprecated. I have not had any success using the new method. It fails with an unknown error -11800. I can save my MOV file using the deprecated method fine, but when I create the equivalent with the new method it fails every time.
Here is my original code:
dispatch_async(movieWritingQueue, ^{
if ([self.assetWriter finishWriting]) {
self.assetWriterAudioIn = nil;
self.assetWriterVideoIn = nil;
//[assetWriter release]; ARC will not allow this line.
self.assetWriter = nil;
self.readyToRecordVideo = NO;
self.readyToRecordAudio = NO;
[self.delegate movieReadyToSaveForMovieProcessor:self];
}
else {
[self displayError:[assetWriter error]];
dispatch_async(dispatch_get_main_queue(), ^{
[self resumeCaptureSession];
});
}
}];
My new method is as follows:
dispatch_async(movieWritingQueue, ^{
[self.assetWriter finishWritingWithCompletionHandler:^{
if (self.assetWriter.status != AVAssetWriterStatusFailed && self.assetWriter.status == AVAssetWriterStatusCompleted) {
self.assetWriterAudioIn = nil;
self.assetWriterVideoIn = nil;
self.assetWriter = nil;
self.readyToRecordAudio = NO;
self.readyToRecordVideo = NO;
[self.delegate movieReadyToSaveForMovieProcessor:self];
} else {
[self displayError:self.assetWriter.error];
dispatch_async(dispatch_get_main_queue(), ^{
[self resumeCaptureSession];
});
}
}];
}];
I don't think I missed anything and I'm not getting much from the error it throws. Any help will be greatly appreciated.
Thanks, Rob
I finally found the answer. The finishWritingWithCompletionHandler:
was failing because I did not run the markAsFinished
on the AVAssetWriterInput
objects. Once I ran the markAsFinished
methods before the finishWritingWithCompletionHandler:
, the process was able to complete without errors.
I had similar problem and found that the handler didn't get called because I released the AVAssetWriter
immediately after calling finishWritingWithCompletionHandler:
, e.g.
[self.assetWriter finishWritingWithCompletionHandler:^{
...
}]
self.assetWriter = nil;
To fix it, just move the releasing line to inside the completion handler:
[self.assetWriter finishWritingWithCompletionHandler:^{
...
self.assetWriter = nil;
}]
The answer was for me to remove calling finishWritingWithCompletionHandler
. Apparently the function was already called once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With