AVCaptureSession和AVCaptureMovieFileOutput帧时间戳 [英] AVCaptureSession and AVCaptureMovieFileOutput frame timestamp

查看:258
本文介绍了AVCaptureSession和AVCaptureMovieFileOutput帧时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AVCaptureSession和AVCaptureMovieFileOutput录制电影。我还记录加速度数据并尝试将加速度数据与视频对齐。

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];

然而,根据我的测试,视频录制在调用startRecordingToOutputFileURL之前0.12秒开始。我假设这是因为各种视频缓冲区已经充满了添加到文件中的数据。

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.

无论如何都要获得第一帧的实际NSDate视频?

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

推荐答案

如果我的问题正确,你想知道记录第一帧的时间戳。你可以尝试

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
 }

这篇关于AVCaptureSession和AVCaptureMovieFileOutput帧时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆