ios xcode GPUimage 视频录制和静态图像捕捉

标签 ios video-capture gpuimage image-capture

我正在开发的应用程序允许用户使用所选效果录制视频。它基于 GPUIamge FilterShowcase 示例。

我刚刚添加了捕获当前所选视频效果的静态图像的选项。

捕获静止图像可以工作,但速度非常慢。从调用捕获静止图像方法到实际保存图像有一个较长的延迟(1到2秒)。

有没有更优化的方法来实现这一点?

谢谢。

代码如下:

-(IBAction)savePhotoWithEffects:(id)sender
{

    // disable buttons - prevent user 
    btnPhoto.enabled=NO;
    btnRecord.enabled=NO;

    // stop videoCamera capture
    [videoCamera stopCameraCapture];

    [stillCamera capturePhotoAsImageProcessedUpToFilter:filter withCompletionHandler:^(UIImage *captureImage, NSError *error){

        if (error) {
            NSLog(@"ERROR: Could not capture!");
        }
        else {
            // save file

            NSLog(@"PHOTO SAVED - ??");

            // save photo to album
            UIImageWriteToSavedPhotosAlbum(captureImage, nil, nil, nil);
        }

        runOnMainQueueWithoutDeadlocking(^{

                 // Start video camera capture again
                 [videoCamera startCameraCapture];

                  // enable the take photo and start recording buttons again
                 btnPhoto.enabled=YES;
                 btnRecord.enabled=YES;

             });

    }];

}

最佳答案

如果我不得不猜测,我会说延迟来自于尝试同时运行 GPUImageStillCamera 和 GPUImageVideoCamera。你可以尝试做这样的事情:

[videoCamera pauseCameraCapture];
UIImage *capturedImage = [filter imageFromCurrentlyProcessedOutput];
UIImageWriteToSavedPhotosAlbum(capturedImage, nil, nil, nil);
[videoCamera resumeCameraCapture];

这样你就根本不需要 GPUImageStillCamera。希望这有帮助!

关于ios xcode GPUimage 视频录制和静态图像捕捉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20152989/

相关文章:

ios - swifty Json 解析数据显示为零?

ios - 如何在 TableView 或标签中提取和显示必要的数据

ios - 在 Xcode SpriteKit 中,使用 Swift 在一个方向上展开 SKSpritenode

comparison - 机器人框架,如何比较声音、视频文件

Android - 从应用程序获取视频时有没有办法定义视频分辨率?

python - 来自多个摄像机的视频拼接

ios - 使用 GPUImagePerlinNoiseFilter 生成图像

iphone - 使用什么模型为 iPhone 应用程序提供翻译?

ios - 来自 gpuimage lib 的 imageFromCurrentFramebuffer 保存黑帧

iphone - 使用 GPUImageRGBFilter