SDL_AcquireCameraFrame returns frames at a higher FPS than specified on macOS 14.6.1
I've encountered an issue where SDL_AcquireCameraFrame is returning frames at a rate higher than expected. Specifically, although the camera is configured to operate at 30 FPS, frames are being returned at a rate exceeding 50 FPS. This behavior is leading to increased CPU usage by the application that processes these frames. I have confirmed that SDL_GetCameraFormat indeed returns frame rate as 30 FPS.
Is it the built in camera on a MacBook? Have you tried reproducing this with testcamera?
This issue isn't with the MacBook's built-in camera; it's concerning a USB camera connected via USB-C. I will conduct tests using testcamera and provide updates on the results.
Created a PR to add performance logging in testcamera: https://github.com/libsdl-org/SDL/pull/10525.
With the implemented changes, here are the observed results:
2024-08-11 12:52:00.856 testcamera[57062:521682] Camera approved! 2024-08-11 12:52:00.856 testcamera[57062:521682] Camera Spec: 1920x1080 30.00 FPS SDL_PIXELFORMAT_YUY2 2024-08-11 13:19:00.614 testcamera[57062:521682] SDL_AppIterate() called 152967 times in the last minute 2024-08-11 13:19:00.614 testcamera[57062:521682] SDL_AcquireCameraFrame() FPS: 61.07 2024-08-11 13:20:00.593 testcamera[57062:521682] SDL_AppIterate() called 18094 times in the last minute 2024-08-11 13:20:00.593 testcamera[57062:521682] SDL_AcquireCameraFrame() FPS: 59.20 2024-08-11 13:21:00.592 testcamera[57062:521682] SDL_AppIterate() called 3600 times in the last minute 2024-08-11 13:21:00.592 testcamera[57062:521682] SDL_AcquireCameraFrame() FPS: 60.00
This issue can be consistently reproduced using the testcamera application.