AVCaptureSession和AVCaptureMovieFileOutput帧时间戳
我正在用AVCaptureSession和AVCaptureMovieFileOutput录制电影。 我也在录制加速度数据,并尝试将加速度数据与videoalignment。
我试图找出一种方法来获得开始video文件的时间。 我正在做以下事情:
currentDate = [NSDate date]; [output startRecordingToOutputFileURL:fileUrl recordingDelegate:self];
但是,根据我的testing,在开始调用startRecordingToOutputFileURL之前,video录制开始0.12秒。 我假设这是因为各种video缓冲区已经充满了数据被添加到文件。
反正有没有得到video的第一帧的实际NSDate?
如果我正确地得到你的问题,你想知道什么时候logging第一帧的时间戳。 你可以试试
CMTime captureStartTime = nil; - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { if !captureStartTime{ captureStartTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); } // do the other things you want }