小编Sub*_*sis的帖子

在iOS中使用AVCaptureMovieFileOutput和AVCaptureVideoDataOutput暂停和恢复视频捕获

我必须实现在单个会话中重复暂停和恢复视频捕获的功能,但是将每个新段(每次暂停后捕获的段)添加到同一视频文件中AVFoundation.目前,每当我再次按"停止"然后再"记录"时,它只会将新的视频文件保存到我的iPhone的文档目录中,并开始捕获到新文件.我需要能够按下"记录/停止"按钮,仅在记录处于活动状态时捕获视频和音频...然后当按下"完成"按钮时,将一个包含所有段的AV文件放在一起.所有这些都需要在同一个捕获会话/预览会话中发生.

我没用AVAssetWriterInput.

我能想到尝试这个的唯一方法是按下"完成"按钮,获取每个单独的输出文件并将它们组合成一个文件.

此代码适用于iOS 5,但不适用于iOS 6.实际上,对于iOS 6,我第一次暂停录制(停止录制)AVCaptureFileOutputRecordingDelegate方法(captureOutput: didFinishRecordingToOutputFileAtURL: fromConnections: error:),但在此之后,当我开始录制时,captureOutput: didFinishRecordingToOutputFileAtURL: fromConnections: error:再次调用委托方法()但是在停止录制时不会调用它.

我需要一个解决这个问题的方法.请帮我.

//View LifeCycle
- (void)viewDidLoad
{
[super viewDidLoad];

self.finalRecordedVideoName = [self stringWithNewUUID];

arrVideoName = [[NSMutableArray alloc]initWithCapacity:0];
arrOutputUrl = [[NSMutableArray alloc] initWithCapacity:0];

CaptureSession = [[AVCaptureSession alloc] init];


captureDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
if ([captureDevices count] > 0)
{
    NSError *error;
    VideoInputDevice = [[AVCaptureDeviceInput alloc] initWithDevice:[self backFacingCamera] error:&error];
    if (!error)
    {
        if ([CaptureSession canAddInput:VideoInputDevice])
            [CaptureSession addInput:VideoInputDevice];
        else
            NSLog(@"Couldn't add video …
Run Code Online (Sandbox Code Playgroud)

iphone video-processing avcapturesession

10
推荐指数
1
解决办法
3586
查看次数