packages icon indicating copy to clipboard operation
packages copied to clipboard

[camera_avfoundation] enable more than 30 fps

Open misos1 opened this issue 1 year ago • 1 comments

Camera plugin was crashing when I tried to set fps to 60 on most media presets (except maybe on 1280x720, although tested device supports 60 fps for up to 1920x1440 and can do 240 fps on 1280x720) because when is activeVideoMinFrameDuration and activeVideoMaxFrameDuration set to fps outside of what active format supports it throws exception. Now it tries to find a format which supports fps closest to wanted fps and clamps it if it cannot be set to exact value to prevent crashes. It searches for formats with the exact same resolution. For example in format list it can be like "1920x1080 { 3- 30 fps}", "1920x1080 { 3- 60 fps}" and "1920x1080 { 6-120 fps}, but when setting sessionPreset then "1920x1080 { 3- 30 fps}" is selected by default. On the tested device there are 2 "media subtypes" 420f and 420v for each format where the first is denoted as "supports wide color" in debug description and the system has tendency to choose this one. So it tries to preserve the media subtype to what is preferred by the system and this is also added to highestResolutionFormatForCaptureDevice (with lower priority than max resolution/fps). Also there was nested lockForConfiguration and unlockForConfiguration when using ResolutionPreset.max together with setting up fps.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

misos1 avatar Aug 12 '24 17:08 misos1

@misos1 Could you split this into two different PRs? Having non-trivial changes to two unrelated plugins in the same PR makes review much more difficult.

stuartmorgan-g avatar Aug 21 '24 11:08 stuartmorgan-g

Sorry, this slipped through the cracks on getting landed.

(@hellohuanlin Please make sure to add the autosubmit label when doing the last review on a non-member PR.)

stuartmorgan-g avatar Nov 05 '24 20:11 stuartmorgan-g