SDL3 Camera Frame Rate Limited to 20 FPS on Apple M1
I'm experiencing an issue where the camera frame rate is limited to 20 FPS on the Apple M1 chip, despite setting the camera to operate at 30 FPS. The camera is capable of supporting up to 60 FPS.
In contrast, the same camera and settings achieve 30 FPS on the Apple M2 chip.
We just pushed some camera framerate fixes a few minutes ago; can you retest with the latest in revision control?
I retested with the most recent version and encountered an error stating "camera spec format not available" when trying to open the camera. Upon reviewing the latest updates, it appears that the function ChooseBestCameraSpec() is not selecting an appropriate colorspace.
Can confirm, testcamera also doesn't run at all:
testcamera:
./build/test/testcamera
2024-06-25 14:19:53.089 testcamera[2694:932729] INFO: Saw 2 camera devices.
2024-06-25 14:19:53.089 testcamera[2694:932729] INFO: - Camera #0: FaceTime HD Camera
2024-06-25 14:19:53.089 testcamera[2694:932729] INFO: - Camera #1: OBS Virtual Camera
2024-06-25 14:19:54.123 testcamera[2694:932729] DEBUG: Cannot create AVCaptureDeviceInput
2024-06-25 14:19:54.123 testcamera[2694:932729] INFO: Failed to open camera device: Cannot create AVCaptureDeviceInput
2024-06-25 14:19:54.123 testcamera[2694:932729] DEBUG: Parameter 'camera' is invalid
2024-06-25 14:19:54.123 testcamera[2694:932729] DEBUG: Parameter 'texture' is invalid
SDL_GetError(): camera spec format not available
Can be fixed by commenting out this continue statement (SDL_camera_coremedia.m):
Camera capture works as intended after that.
What is the device format and colorspace? Why are they different now from when they were enumerated?
Looks like it doesn't pass if spec->colorspace is set to 0 in COREMEDIA_OpenDevice, but i'm properly setting it to a non-zero value in SDL_OpenCameraDevice. Investigating further...
I retested with the most recent version and encountered an error stating "camera spec format not available" when trying to open the camera. Upon reviewing the latest updates, it appears that the function ChooseBestCameraSpec() is not selecting an appropriate colorspace.
Yup, that's it, closest->colorspace is never set in ChooseBestCameraSpec function if we request a specific camera spec in SDL_OpenCameraDevice.
Fixed it, merge request will be soon