2

This is a strange problem. I have not changed any code involving this in my project but my video recording has randomly stopped working. When I try to save to a movie to a file I get the following error:

Error Domain=NSOSStatusErrorDomain Code=-12780 "The operation couldn’t be completed. (OSStatus error -12780.)"

I start my capture with the following code:

- (void)initVideoCapture {
self.captureSession = [[AVCaptureSession alloc] init];

AVCaptureDevice *videoCaptureDevice = [self frontFacingCameraIfAvailable];
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:nil];
[self.captureSession addInput:videoInput];

aMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];    
[self.captureSession addOutput:aMovieFileOutput];
[self detectVideoOrientation:aMovieFileOutput];

[self.captureSession setSessionPreset:AVCaptureSessionPresetMedium];

[self.captureSession startRunning];

}

I then call this method from the viewController to start recording:

- (void) startRecord {
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"yyyyMMddHHmmss"];
NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]];
[outputFormatter release];

NSString * fileString = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mov",newDateString]];
recordFileURL = [[NSURL alloc] initFileURLWithPath:fileString];        

[aMovieFileOutput startRecordingToOutputFileURL:recordFileURL recordingDelegate:self];

}

At this time I get the error in this function.

  • (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error

What is really weird is that it randomly works sometimes. Like, I will compile the project and it will work 100% of the time. Next time I compile it will work 0%. What could I be doing wrong? Anything obvious?

2 Answers 2

6

I've gotten -12780 when the orientation of the device was UIDeviceOrientationFaceUp, UIDeviceOrientationFaceDown and UIDeviceOrientationUnknown. Since a recoded video's orientation has to be portrait or landscape, it'll error out on you. I had to write a quick method that checks for those three, and just translates them to portrait.

1
  • 3
    You are right.I meet this issue too.Could you tell me how you translate the orientation??I don't know how to change it.It's read-only.Thanks~~ Dec 3, 2012 at 9:22
-3

this seems to be a bug with apple. i solved it by using AVAssetWriter and AVAssetWriterInput

1
  • Can you provide more detail into how you solved this? Thanks! Apr 11, 2012 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.