I am trying to start recording a video at an exact timestamp.
I have managed to get the timestamp of each frame by using the methods found: here and here.
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection{
CMTime time = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
...
// check if time > timestampToStart, use these frames
}
By doing this I can use only frames that come after the timestamp I specify.
The issue is that the first frame used won't be exactly at timstampToStart but timstampToStart plus a small interval that can be between 0-1/fps (fps = 24 usually).
How can I make sure that the first frame used is exactly (or very close) to the timestamp that I want