IMX519 MJPEG Encoder

  1. Where did you get the camera module(s)?
    From Arducam China

  2. Model number of the product(s)?
    16MP IMX519

  3. What hardware/platform were you working on?
    Raspberry Pi 4b / 64-bit Pi OS Lite bookworm

  4. Instructions you have followed. (link/manual/etc.)

  5. Problems you were having?

I have an Arducam 16MP IMX519 camera, and I am able to capture images at the highest resolution using the mjpeg codec through the command line:

libcamera-vid -n --codec mjpeg -t 10000 --segment 1 -o test_%04d.jpg --width 4656 --height 3496 --brightness 0.0 --contrast 1.0 --exposure normal --gain 3 --awb auto --metering centre --saturation 1.0 --sharpness 1.0 --denoise cdn_off --quality 95

with a frame rate of about 8-9 frames.

However, when I try to capture images using picamera2, I encounter an error. My code is as follows:

import time
import libcamera
from picamera2 import Picamera2
from picamera2.encoders import H264Encoder,MJPEGEncoder
from libcamera import controls
picam2 = Picamera2()
video_config = picam2.create_video_configuration({“size”: (4656, 3496)})

picam2.configure(video_config)
picam2.set_controls({“AfMode”: controls.AfModeEnum.Continuous, “FrameRate”: 1})
encoder = MJPEGEncoder(10000000)

picam2.start_recording(encoder, ‘test.mjpeg’)
time.sleep(10)
picam2.stop_recording()

Error message:

dmesg