Use small preview buffer for HQ camera, so long exposures can complete with 128MB GPU RAM
With the HQ camera I found to get picamera to take a photo with 128MB GPU RAM for long exposures I had to set the preview buffer size to around 1920x1080, so that it would not run out of resources.
This pull request attempts first to use the maximum preview buffer, if this fails it tries again with 1920x1080 sized preview buffers.
In the process of switching to the smaller preview buffer size, I note the following message is printed:
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
I am wondering if it may be possible to hide this?
I found from - https://github.com/waveform80/picamera/issues/627#issuecomment-631394933 that raspistill uses 1080p max preview buffer size.
I noticed when I installed Raspberry Pi OS from scratch and then enabled the camera with raspi-config, /boot/config.txt GPU memory was then set to:
gpu_mem=128
If this argument is removed, the GPU RAM available (found using: vcgencmd get_mem gpu), appeared to be 76MB, which wasn't enough for a long exposure to complete with picamera (even when using a preview resolution of 320x240).
So provided you enable the camera with raspi-config, the gpu_mem field is set programmatically to 128MB.