IMX519 autofocus and camera-streamer streaming cannot work together in OctoPrint on Raspberry Pi

Hi everyone. I’m trying to get an IMX519 camera working with OctoPrint on a Raspberry Pi. I’m on the latest OctoPrint image, which uses camera-streamer for the stream. I’ve installed libcamera (libcamera_dev and libcamera_apps), but the camera feed in OctoPrint never appears. The camera seems to be detected, but the stream just doesn’t show up. Has anyone run into this with the latest image?

Hey, could you post the exact setup commands you ran and also test a still capture directly with libcamera-still? That will help narrow down whether this is a camera/driver issue or something specific to camera-streamer.

Sure. I ran the Pivariety setup like this:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps
libcamera-still --lens-position 5 -o test_5.jpg

The still capture works really well - the photo is sharp, autofocus works, and --lens-position 5 is respected. But camera-streamer still doesn’t show any stream in OctoPrint.

Thanks, that’s useful. The next thing I’d try is reinstalling camera-streamer first, then reinstalling libcamera-apps afterward. camera-streamer pulls in its own libcamera version, so the order matters here. Let me know if the stream appears and whether autofocus/lens-position still work after that.

I did the reinstall in that order - camera-streamer first, then libcamera-apps again. Now the stream does appear in OctoPrint. But autofocus and lens position control are gone; libcamera-still doesn’t respond to --lens-position the way it did before. I’ve toggled back and forth between the drivers several times and it’s always one or the other - stream working or focus control working, never both.

That confirms the root cause. The camera-streamer used by the latest OctoPrint image and the Arducam libcamera/libcamera-apps stack are not compatible. camera-streamer needs a different libcamera version than the Arducam driver, so toggling between them will only ever trade one feature for the other. You can’t have streaming and the advanced autofocus/lens controls at the same time on the latest image.

For now, the workaround is to use the older OctoPrint version instead of the latest image. I’ve attached the old version guide for reference. On that image, run the same Pivariety setup:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps
libcamera-still --lens-position 5 -o test_5.jpg

libcamera-still --lens-position 5 should still give a sharp photo with autofocus and lens position working.

Thanks, I switched to the older OctoPrint setup and the stream is working now, but the image is super blurry. The camera and lens are fine because running this manually gives a great sharp photo:

libcamera-still --lens-position 5 -o test_5.jpg

I tried to lock that focus setting for the stream by adding this to octopi.txt:

camera_libcamera_options=“-afmode manual --lens-position 5”

After a reboot the stream wouldn’t load at all, so I reverted the change. Here’s a screenshot of the blurry stream:

Is there any supported way to apply the manual lens position to the OctoPrint stream?

I can see the blur in the screenshot. Right now there isn’t a supported method to apply the manual lens position globally to OctoPrint/camera-streamer. The octopi.txt option you tried is the logical approach, but as you found it breaks the stream on reboot, so it has to be reverted.

To summarize: libcamera-still --lens-position 5 -o test_5.jpg works for stills and confirms the hardware is okay, but locking that manual focus for the live stream isn’t currently possible. I don’t have a solution for the focus-setting requirement at this time.

For reference, here’s the sharp still comparison: