AVCaptureSession 暂停和恢复录制

Sam*_*m B 5 iphone objective-c avfoundation ios

我正在使用 AVCaptureSession 为 iOS 5.0 制作电影应用程序。我赋予用户开始-暂停-开始-停止录制电影的能力

我定义的三个按钮是

  • 开始录音

  • 停止录音

  • 暂停录音

我能够成功开始和停止录音。我无法做的是暂停录音,然后再次恢复。我在堆栈溢出时查看了这个问题/答案,但我不知道他们是如何暂停和恢复视频的?我确实在这里找到了一些其他的帖子,但没有一个有任何我可以用来尝试的示例代码。如果 AVAssetWrtier 是要走的路,你如何将它与 AVCaptureSession 一起使用?

ios - 暂停视频录制

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

这是我的三个按钮的代码

        -(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);    

    }
}
Run Code Online (Sandbox Code Playgroud)

Sam*_*m B 1

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

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