2026-05-31
Decision
Performance
@antoinecellerier
picamera2.create_video_configuration() defaults the main stream to XBGR8888
(32 bits/pixel). Both the V4L2 hardware encoders (MJPEGEncoder,
H264Encoder) and the JpegEncoder software fallback accept YUV420
(12 bits/pixel) as a native input. Forcing YUV420 upstream of the encoders
skips an implicit colour-space conversion and reduces DMA bandwidth by ~2.7×.
- Keep the picamera2 default (
XBGR8888). - Request
YUV420for the main stream, falling back to the picamera2 default when the camera does not advertise it.
We request YUV420 for the main stream when libcamera reports it as supported,
selected from a preference-ordered list of encoder-compatible formats with
YUV420 first. If none are supported, we omit format from the config and
defer to the picamera2 default.
- Measured CPU on a Pi 4B with Camera Module 3 at 1920×1080 @ 30 fps drops by
~28–39 % (idle and live WebRTC respectively) versus the
XBGR8888default. - No expected image-quality impact: JPEG and H.264 both encode in YUV internally, so this change moves the colour-space conversion earlier in the pipeline rather than introducing a new one.