【问题标题】:Cannot save a live video file in gpuimage framework objective c无法在 gpuimage 框架目标 c 中保存实时视频文件
【发布时间】:2016-08-31 14:06:45
【问题描述】:

我正在通过导入 GPUImage 框架为 ios 创建具有实时视频功能的相机应用程序。我使用这个框架来制作实时照片,它运行良好。我使用以下代码制作实时视频,并参考了 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];

我的疑惑: 如何将视频保存到照片库。我查看了他们使用 url 的其他博客,我不确定如何实现照片库的 url。 我使用以下代码将实时视频保存到照片库,但找不到视频捕获。

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

我想知道,如何找到 pathToMovie?

请帮忙。提前致谢。

【问题讨论】:

  • 我搜索了所有博客,但没有解决方案..请帮助我..

标签: objective-c gpuimage gpuimagestillcamera


【解决方案1】:

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

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];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多