我通过设置最长持续时间限制,使用AVCaptureMovieFileOutput
录制了电影文件。
例如:如果我想录制10秒视频,我已经设置了电影文件的最大持续时间和其他属性,如下所示......
Float64 TotalSeconds = 10;
int32_t preferredTimeScale = 30
CMTime maxDuration = CMTimeMakeWithSeconds(TotalSeconds, preferredTimeScale);
aMovieFileOutput.maxRecordedDuration = maxDuration;
aMovieFileOutput.minFreeDiskSpaceLimit = 1024 * 1024;
但录制的视频只显示了9秒(我使用MPMoviePlayerController
播放),为什么会出现时差...如何准确录制10秒。我在设置最长持续时间时做错了什么。感谢名单。
答案 0 :(得分:0)
请确保输出的帧率良好
#define CAPTURE_FRAMES_PER_SECOND 30
//SET THE CONNECTION PROPERTIES (output properties)
AVCaptureConnection* captureConnection = [self.movieFileOutput connectionWithMediaType:AVMediaTypeVideo];
if(captureConnection.supportsVideoMinFrameDuration) captureConnection.videoMinFrameDuration = CMTimeMake(1,CAPTURE_FRAMES_PER_SECOND);
if(captureConnection.supportsVideoMaxFrameDuration) captureConnection.videoMaxFrameDuration = CMTimeMake(1,CAPTURE_FRAMES_PER_SECOND);
CMTimeShow(captureConnection.videoMinFrameDuration);
CMTimeShow(captureConnection.videoMaxFrameDuration);