From 2954532019daf74fa9da44a5850ed2b28b8f0f77 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Tue, 21 Oct 2025 16:44:07 +0200 Subject: [PATCH] mac-avcapture: Use fallback frame rate by default for new devices When a new device is selected, a best-possible frame rate is chosen for the initial configuration of the device. This has to be set in the source settings, as those are the "source of truth" for the properties and the device configuration. The object has to be created explicitly first before setting the frame rate value. The source then has to be updated explicitly as well to ensure that the change will be picked up by the next iteration of the render thread to "tick" the source and thus make it configure a capture session with the fallback framerate set. --- plugins/mac-avcapture/OBSAVCapture.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/mac-avcapture/OBSAVCapture.m b/plugins/mac-avcapture/OBSAVCapture.m index 29ce8e9c4..1938b538a 100644 --- a/plugins/mac-avcapture/OBSAVCapture.m +++ b/plugins/mac-avcapture/OBSAVCapture.m @@ -417,6 +417,23 @@ static const UInt32 kMaxFrameRateRangesInDescription = 10; OBSAVCaptureMediaFPS fps; if (!obs_data_get_frames_per_second(self.captureInfo->settings, "frame_rate", &fps, NULL)) { [self AVCaptureLog:LOG_DEBUG withFormat:@"No valid framerate found in settings"]; + + AVCaptureDeviceFormat *lastFormat = [self.deviceInput.device.formats lastObject]; + + fps = [OBSAVCapture fallbackFrameRateForFormat:lastFormat]; + + if (lastFormat.videoSupportedFrameRateRanges.count == 0) { + return NO; + } + + obs_data_set_obj(self.captureInfo->settings, "frame_rate", NULL); + + obs_data_item_t *frameRateSetting = obs_data_item_byname(self.captureInfo->settings, "frame_rate"); + + obs_data_item_set_frames_per_second(&frameRateSetting, fps, NULL); + + obs_source_update(self.captureInfo->source, self.captureInfo->settings); + return NO; }