0

I have recorded a movie file using AVCaptureMovieFileOutput by setting maximum duration limit. For e.g.: If I want to record 10 seconds video, I had set the max duration and other properties for the movie file like below...

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

But recorded video is showing only 9 seconds (which I played using MPMoviePlayerController), why is that time difference.. How to record exactly 10 seconds. Am I doing anything wrong while setting maximum duration. Thanx.

Venk
  • 5,949
  • 9
  • 41
  • 52
Newbee
  • 3,231
  • 7
  • 42
  • 74

1 Answers1

0

Please be sure to have the good framerate for the output

#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);
xeonarno
  • 426
  • 6
  • 17