【问题标题】:ios xcode GPUimage video recording and still image captureios xcode GPUimage 视频录制和静止图像捕获
【发布时间】:2013-11-22 19:28:48
【问题描述】:

我正在开发的应用程序允许用户录制具有所选效果的视频。它基于 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;

             });

    }];

}

【问题讨论】:

    标签: ios video-capture gpuimage image-capture


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

      你的情况没问题。只是在取帧之前不要停止捕捉视频

      // 禁用按钮 - 阻止用户 btnPhoto.enabled=否; btnRecord.enabled=否;

      [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(^{
      
                    // enable the take photo and start recording buttons again
                   btnPhoto.enabled=YES;
                   btnRecord.enabled=YES;
      
               });
      
      }];
      

      }

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多