0

我有一个 iPhone 摄像头附件,它以 9FPS 的速度捕获视频,并将其作为单独的 UIImages 提供。我正在尝试将这些图像拼接在一起,以创建相机使用 AVFoundation 看到的延时视频。

我不确定如何正确转换帧和时间以实现我想要的时间压缩。

例如 - 我希望将 1 小时的真实生活镜头转换为 1 分钟的时间流逝。这告诉我,我需要每 60 帧捕获一次并将其附加到延时摄影中。

下面的代码是否完成了 60 秒到 1 秒的延时转换?还是我需要添加更多的乘法/除法kRecordingFPS

#define kRecordingFPS 9
#define kTimelapseCaptureFrameWithMod 60
//frameCount is the number of frames that the camera has output so far
if(frameCount % kTimelapseCaptureFrameWithMod == 0)
{
    //...
    //convert image and prepare it for recording
    [self appendImage:image 
               atTime:CMTimeMake(currentRecordingFrameNumber++, kRecordingFPS)];
}
4

1 回答 1

1

您的代码将每 1/9 秒在您的电影中制作 60 帧中的 1 帧,并且每次将 frameIndex 增加 1。

结果应该是 [frameCount 的最大值] / (60 * 9) 的影片。如果您有 32400 帧(9fps 的 1 小时电影),则电影将是 {540:9 = 60s}。

尝试在每次调用appendImage:atTime:检查时使用 CMTimeShow() 打印 CMTime。

//at 5 fps, 300 frames recorded per 60 seconds
//to compress 300 frames into 1 second at 5 fps, we need to take every 300/5 = 60th frame
//to compress 300 frames into 1 second at 15 fps, take every 300/15 = 20th frame
//to compress 300 frames into 1 sec at 30 fps, take every 300/30 = 10th frame

#define kReceivedFPS 9
#define kStoreFPS 9
#define kSecondsPerSecondCompression 60

#define kTimelapseCaptureFrameWithMod (kSecondsPerSecondCompression * kReceivedFPS) / kStoreFPS
于 2016-01-27T17:35:46.630 回答