0

AVCaptureMovieFileOutput通过设置最大持续时间限制记录了一个电影文件。例如:如果我想录制 10 秒的视频,我已经为电影文件设置了最大持续时间和其他属性,如下所示......

         Float64 TotalSeconds = 10;
        int32_t preferredTimeScale = 30
        CMTime maxDuration = CMTimeMakeWithSeconds(TotalSeconds, preferredTimeScale);
        aMovieFileOutput.maxRecordedDuration = maxDuration;
        aMovieFileOutput.minFreeDiskSpaceLimit = 1024 * 1024;

但是录制的视频仅显示 9 秒(我使用 播放MPMoviePlayerController),为什么会有那个时差.. 如何准确录制 10 秒。我在设置最大持续时间时做错了什么。谢谢。

4

1 回答 1

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);
于 2014-01-17T05:11:06.303 回答