0

I'm creating the camera app for ios with live video features by importing GPUImage framework.I used this framework for live photos it was working good.I used the following code for live video with the reference of Brad github,

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

startfilter = [[GPUImageFilter alloc] init];
outputView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0,self.view.frame.size.width,self.view.frame.size.height)];
 [self.image_view addSubview:outputView];
[startfilter removeAllTargets];
// Add the view somewhere so it's visible
[startfilter forceProcessingAtSize:outputView.sizeInPixels];
[videoCamera useNextFrameForImageCapture];
[videoCamera addTarget:startfilter];
[startfilter addTarget:outputView];

[videoCamera startCameraCapture];

MY doubt : How to save the video to the photo gallery.I reviewed other blogs they are using the urls, I'm not sure how to implement the url for photo gallery. I used the following code to save the live video to the photo gallery, but I couldnt find the video capture.

[videoCamera stopCameraCapture];
UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, nil, nil);

I want to know, how to find pathToMovie?

please help.Thanks in advance.

4

1 回答 1

0

为了参考上述问题,我通过提供以下代码解决了实时视频的相机滚动路径,

pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];

除了我在问题(摄像机启动)中提到的代码,添加以下代码,以便实时视频将在缓冲区中。

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];
[movieFile addTarget:startfilter];
movie_write = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480, 640)];
movie_write.shouldPassthroughAudio=YES;
videoCamera.audioEncodingTarget=movie_write;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movie_write];
[movie_write startRecording];
[movieFile startProcessing];
[videoCamera startCameraCapture];
NSLog(@"Movie completed");

要保存实时视频,以下代码适用于我,

   [startfilter useNextFrameForImageCapture];
    UIImage*process=[[UIImage alloc]init];
    process=[startfilter imageFromCurrentFramebuffer];
     NSLog(@"Image %@",process);

    [videoCamera pauseCameraCapture];

        [startfilter removeTarget:movie_write];
        UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, nil, nil);
       [movie_write finishRecording];
   [videoCamera stopCameraCapture];
于 2016-05-16T15:10:33.293 回答