AVCaptureSession暂停和恢复录制

我正在使用AVCaptureSession为iOS 5.0制作电影应用。 我正在为用户提供开始 – 暂停 – 开始 – 停止录制电影的能力

我定义的三个按钮是

  • 开始录制

  • 停止录制

  • 暂停录制

我能够成功开始和停止录制。 我无法做的是暂停录制然后再次恢复。 我在堆栈溢出时查看了这个问题/答案,但我不知道他们如何暂停和恢复video? 我确实在这里发现了一些其他post,但没有一个我可以用来试用它的示例代码。 如果AVAssetWrtier是如何使用AVCaptureSession如何使用它?

ios – 暂停video录制

使用iOS中的AVFoundation暂停和恢复同一文件的video捕获

这是我的三个按钮的代码

-(IBAction) makeMovieNow { NSLog(@"makeMovieNow ..."); [session startRunning]; [movieFileOutput startRecordingToOutputFileURL:movieURL recordingDelegate:self]; } -(IBAction) makeMovieStop { NSLog(@"makeMovieStop ..."); //stop recording [session stopRunning]; } -(IBAction) makeMoviePause { NSLog(@"makeMoviePause ..."); //pause video??? How? } //********** DID FINISH RECORDING TO OUTPUT FILE AT URL ********** - (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error { NSLog(@"didFinishRecordingToOutputFileAtURL - enter"); BOOL RecordedSuccessfully = YES; if ([error code] != noErr) { NSLog(@"ERROR RECODING MOVIE!!! - enter"); // A problem occurred: Find out if the recording was successful. id value = [[error userInfo] objectForKey:AVErrorRecordingSuccessfullyFinishedKey]; if (value) { RecordedSuccessfully = [value boolValue]; } } if (RecordedSuccessfully) { //----- RECORDED SUCESSFULLY ----- NSLog(@"didFinishRecordingToOutputFileAtURL - success"); UISaveVideoAtPathToSavedPhotosAlbum(videoPath2, self, nil, nil); } } 

在http://www.gdcl.co.uk/2013/02/20/iPhone-Pause.html上有一个样本iPhone就是这样做的。 它使用数据输出而不是电影文件输出,以便将数据传递给应用程序。 然后,如果启用了录制,应用程序会将示例传递给AVAssetWriter,并且在暂停/恢复之后,会调整时间戳以删除暂停。

G

我最终创建了两个文件并将它们合并在一起。 以下是示例代码和教程

http://www.raywenderlich.com/13418/how-to-play-record-edit-videos-in-ios