AVCaptureSession and AVCaptureMovieFileOutput fram

2019-04-20 09:20发布

I am recording a movie with AVCaptureSession and AVCaptureMovieFileOutput. I am also recording acceleration data and trying to align the acceleration data with the video.

I am trying to figure out a way to get the time the video file recording started. I am doing the following:

currentDate = [NSDate date];
[output startRecordingToOutputFileURL:fileUrl recordingDelegate:self];

However, according to my tests, the video recording starts 0.12 seconds before the call to startRecordingToOutputFileURL is made. I'm assuming this is because the various video buffers are already full of data which get added to the file.

Is there anyway to get the actual NSDate of the first frame of the video?

1条回答
Emotional °昔
2楼-- · 2019-04-20 09:42

if i get your question correctly, you want to know the timestamp of when the first frame is recorded. you could try

CMTime captureStartTime = nil;

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { 

      if !captureStartTime{ 
         captureStartTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
      }
  // do the other things you want
 }
查看更多
登录 后发表回答