小编i.j*_*han的帖子

Avfoundation - 同时播放和录制视频(以及音频和预览)

我正在尝试同时录制和播放视频.这有可能与avfoundation?目前我能够做到这一点,只要我不录制音频.只要我将音频输入添加到AVCaptureSession并重新启动整个内容,我就会收到"AVCaptureSessionWasInterruptedNotification"并停止录制.

这就是我播放视频的方式.

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc]     initWithContentURL:[NSURL fileURLWithPath:path]];
[moviePlayer.view setFrame:self.playerView.bounds];
moviePlayer.useApplicationAudioSession=NO;
self.player = moviePlayer;

[moviePlayer release];

[self.playerView addSubview:player.view];

[player play];
Run Code Online (Sandbox Code Playgroud)

这就是我录制视频的方式:

NSError *error;

AVCamCaptureManager *captureManager = [[AVCamCaptureManager alloc] init];



if ([captureManager setupSessionWithPreset:AVCaptureSessionPresetLow error:&error])
{
    [self setCaptureManager:captureManager];



     AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[captureManager session]];
     self.captureVideoPreviewLayer= previewLayer;

     UIView *view = [self cameraView];
     CALayer *viewLayer = [view layer];
     [viewLayer setMasksToBounds:YES];

     CGRect bounds = [view bounds];


     [captureVideoPreviewLayer setFrame:bounds];

     if ([captureVideoPreviewLayer isOrientationSupported]) 
     [captureVideoPreviewLayer setOrientation:AVCaptureVideoOrientationPortrait];


     [captureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];


   [[captureManager session] startRunning];

    [self setCaptureVideoPreviewLayer:captureVideoPreviewLayer];

    if ([[captureManager session] …
Run Code Online (Sandbox Code Playgroud)

iphone video video-capture recording avfoundation

6
推荐指数
1
解决办法
5024
查看次数

标签 统计

avfoundation ×1

iphone ×1

recording ×1

video ×1

video-capture ×1