GPUImageVideoCamera在iOS

GPUImageVideoCamera在iOS

本文介绍了GPUImageVideoCamera在iOS 7上保存视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现300 * 300之类的方形视频录制,所以我选择了GPUImage,但它在IOS 7上不起作用,并且给出了[UIView nextAvailableTextureIndex]: unrecognized selector sent to instance之类的错误,当我们构建偶数示例代码时,错误开始尝试保存GPUImageVideoCamera时有时卡在[movieWriter startRecording];GPUImage是否与ios 7兼容,或者我们进行了一些更改?

这是代码

     - (void)viewDidLoad
        {
            [super viewDidLoad];

            videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];


            videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
            videoCamera.horizontallyMirrorFrontFacingCamera = NO;
            videoCamera.horizontallyMirrorRearFacingCamera = NO;

            filter = [[GPUImageSepiaFilter alloc] init];

        initWithRotation:kGPUImageRotateRightFlipVertical];

            [videoCamera addTarget:filter];
            GPUImageView *filterView = (GPUImageView *)self.view;
            [filter addTarget:filterView];
       sharing

            NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
            unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
            NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
            movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)];

            [filter addTarget:movieWriter];

        }



- (IBAction)stopRecording:(id)sender {

    [filter removeTarget:movieWriter];
    videoCamera.audioEncodingTarget = nil;
    [movieWriter finishRecording];

}

- (IBAction)startRecording:(id)sender {

    videoCamera.audioEncodingTarget = movieWriter;
    [movieWriter startRecording];
    [videoCamera startCameraCapture];

}
解决方案

我的猜测是您修改了.xib或情节提要,并且未将显示摄像机预览的视图的类设置为GPUImageView. /p>

I'm trying to achieve the square video recording like 300*300 so I choose GPUImage but its not working on IOS 7 and giving errors like [UIView nextAvailableTextureIndex]: unrecognized selector sent to instance the error starts when we build the even the sample codewhen trying to save the GPUImageVideoCamerasome times its stucks at [movieWriter startRecording]; is the GPUImage compatible with ios 7 or we have made some changes ?

here is the code

     - (void)viewDidLoad
        {
            [super viewDidLoad];

            videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];


            videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
            videoCamera.horizontallyMirrorFrontFacingCamera = NO;
            videoCamera.horizontallyMirrorRearFacingCamera = NO;

            filter = [[GPUImageSepiaFilter alloc] init];

        initWithRotation:kGPUImageRotateRightFlipVertical];

            [videoCamera addTarget:filter];
            GPUImageView *filterView = (GPUImageView *)self.view;
            [filter addTarget:filterView];
       sharing

            NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
            unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
            NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
            movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)];

            [filter addTarget:movieWriter];

        }



- (IBAction)stopRecording:(id)sender {

    [filter removeTarget:movieWriter];
    videoCamera.audioEncodingTarget = nil;
    [movieWriter finishRecording];

}

- (IBAction)startRecording:(id)sender {

    videoCamera.audioEncodingTarget = movieWriter;
    [movieWriter startRecording];
    [videoCamera startCameraCapture];

}
解决方案

My guess is that you modified the .xib or storyboard and didn't set the class of the view that is showing the camera preview to GPUImageView.

这篇关于GPUImageVideoCamera在iOS 7上保存视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 13:14