Vipin K V Ias
Vipin K V Ias

Reputation: 39

How to set videoMaximumDuration for AvcaptureSession in iOS

I am using AVCaptureSession for Recording Video.But i can't able to set maximum Video length.If i am using ImagePicker Controller there is method is used for set maximum video duration like videoMaximumDuration .But In AVCaptureSession how i can set MaximumDuration .please help me..Advance Thanks

Upvotes: 3

Views: 2885

Answers (1)

Jim Tierney
Jim Tierney

Reputation: 4105

You can set the maximum duration using the property maxRecordedDuration of your AVCaptureMovieFileOutput settings.

Here's an example.

self.movieFileOutput = [[AVCaptureMovieFileOutput alloc]init];

Float64 maximumVideoLength = 60; //Whatever value you wish to set as the maximum, in seconds
int32_t prefferedTimeScale = 30 //Frames per second

CMTime maxDuration = CMTimeMakeWithSeconds(maximumVideoLength, preferredTimescale_;

self.movieFileOutput.maxRecordedDuration = maxDuration;

self.movieFileOutput.minFreeDiskSpaceLimit = 1024*1024;

  if(self.captureSession canAddOutput:self.movieFileOutput){
     [self.captureSession addOutput:self.movieFileOutput];

  }

I hope this answers your question

Upvotes: 8

Related Questions