Reputation: 336
If we use AVCaptureMovieFileOutput
, we have recordedDuration
property on it that gives the length of the video recorded.
However I couldn't find anything similar for video recorded using AVCaptureVideoDataOutput
.
Upvotes: 1
Views: 415
Reputation: 36169
If you're using AVCaptureVideoDataOutput
then in your delegate callback
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection;
you can calculate the recorded duration by noting the presentation time stamps of the first and last sampleBuffer
s that you record:
CMTime start = CMSampleBufferGetPresentationTimeStamp(sampleBufferFirst);
CMTime end = CMSampleBufferGetPresentationTimeStamp(sampleBufferLast);
CMTime recordedDuration = CMTimeSubtract(end, start);
Upvotes: 2