我有一个iPhone相机附件,可以9FPS捕获视频并将其作为单独的UIImages提供 . 我正在尝试将这些图像拼接在一起以创建使用AVFoundation相机所看到的内容的间隔拍摄视频 .
我不确定如何正确转换帧和时间来实现我想要的时间压缩 .
例如 - 我希望将1小时的真实片段转换为1分钟的时间间隔 . 这告诉我,我需要捕获每个第60帧并将其附加到游戏中时光倒流 .
Does the code below accomplish 60 seconds to 1 second time lapse conversion? 或者我需要通过 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)];
}
1 回答
你的代码每隔1/9会在你的电影中制作1帧,每次增加一帧frameIndex .
结果应该是[frameCount的最大值] /(60 * 9)的影片 . 如果你有32400帧(1小时的胶片,9fps),这部电影将是{540:9 = 60s} .
尝试在每次调用
appendImage:atTime:
时使用CMTimeShow()打印CMTime以进行检查 .