AVCaptureDevice: Camera frame rate off...

It seems the camera produces unexpected results in terms of not quite matching the frame rate given. Specifically, if I set my AVCaptureDevice's activeVideoMaxFrameDuration and activeVideoMinFrameDuration to a CMTimeMake(1,30) I get a frame rate of 30.02 Hz. More curiously, if I set it to CMTimeMake(100,2997), I get a frame rate of 29.02 Hz, so almost an entire Hz or 3% off. At CMTimeMake(1,25) I get 25.01 Hz, and at CMTimeMake(1,24) I get 24.01 Hz. The times are measured by the frames' CMSampleBufferGetPresentationTimeStamp(). So for the round numbers, I'm about 0.1% off and for 29.97 Hz I'm 3% off. 0.1% may not sound like much, but if I want to record at a fixed standard frame rate it means a lost or extra frame every other minute. This happens both on iPhone 6 and on iPhone 6S, and the numbers were obtained in the 1080p 2-60Hz mode. To explore the oddity yet a bit further, at CMTimeMake(100,2999) I get 29.03 Hz and at CMTimeMake(100,3001) I get 30.02 Hz. So it could be that the camera only supports multiples of 1 Hz frame rate intervals, but not exactly.


To satisfy my curiousity, I wrote a PLL stabilization around the camera that changes the frame rate depending on whether the video stream is currently ahead or behind where it should be, and that sort of works, but only if cinematic stabilization is off, and that also doesn't feel like the right way to use the built-in camera. Am I missing something? In particular, the result where for the 29.97 specification I'm getting 29 Hz seems really odd, given that this is a very common frame rate. Obviously a phone isn't a true real-time operating system and I don't mind individual frames being off a little bit, but there should be enough regulation around it so as not to cause missed frames if I record for a while.

i have sampe quetion,

2 Seconds print

iphone12 min iOS16.0

2023-04-17 11:10:34 131 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:34 130. 2023-04-17 11:10:36 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:36 128. 2023-04-17 11:10:38 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:38 127. 2023-04-17 11:10:40 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:40 128. 2023-04-17 11:10:42 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:42 128. 2023-04-17 11:10:44 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:44 128. 2023-04-17 11:10:46 131 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:46 130. 2023-04-17 11:10:48 131 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:48 130. 2023-04-17 11:10:50 131 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:50 130. 2023-04-17 11:10:52 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:52 129. 2023-04-17 11:10:54 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:54 128. 2023-04-17 11:10:56 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:56 128. 2023-04-17 11:10:58 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:10:58 129. 2023-04-17 11:11:00 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:00 129. 2023-04-17 11:11:02 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:02 127. 2023-04-17 11:11:04 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:04 128. 2023-04-17 11:11:06 131 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:06 130. 2023-04-17 11:11:08 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:08 128. 2023-04-17 11:11:10 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:10 129. 2023-04-17 11:11:12 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:12 129. 2023-04-17 11:11:14 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:14 129. 2023-04-17 11:11:16 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:16 127. 2023-04-17 11:11:18 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:18 128. 2023-04-17 11:11:20 131 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:20 130. 2023-04-17 11:11:22 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:22 129. 2023-04-17 11:11:24 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:24 128. 2023-04-17 11:11:26 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:26 128. 2023-04-17 11:11:28 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:28 129. 2023-04-17 11:11:30 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:30 129. 2023-04-17 11:11:32 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:32 127. 2023-04-17 11:11:34 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:34 129. 2023-04-17 11:11:36 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:36 129. 2023-04-17 11:11:38 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:38 128. 2023-04-17 11:11:40 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:40 127. 2023-04-17 11:11:42 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:42 128. 2023-04-17 11:11:44 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:44 128. 2023-04-17 11:11:46 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:46 129. 2023-04-17 11:11:48 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:48 127. 2023-04-17 11:11:50 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:50 129. 2023-04-17 11:11:52 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:52 127. 2023-04-17 11:11:54 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:54 127. 2023-04-17 11:11:56 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:56 128. 2023-04-17 11:11:58 131 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:11:58 129. 2023-04-17 11:12:00 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:12:00 127. 2023-04-17 11:12:02 130 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:12:02 129. 2023-04-17 11:12:04 128 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:12:04 128. 2023-04-17 11:12:06 129 -[CCSystemCapture captureOutput:didOutputSampleBuffer:fromConnection:] 837行: didOutputSampleBuffer 2023-04-17 11:12:06 128.

AVCaptureDevice: Camera frame rate off...
 
 
Q