A new camera stack for OctoPi

One of the good things about how this image is set up is that the scripts should be upgradable via apt. So running sudo apt update and sudo apt upgrade would be able to update camera-streamer as well as camera-streamer-stack scripts, from https://apt.octoprint.org.

Of course, we haven't yet tried this out in the field - whilst there is still work ongoing, there has not yet been a new release that people could update to should they wish to.

It doesn't change the fact that you would have to re-image to upgrade OctoPi versions in general, it just makes it easier to change the webcam stack.

@Charlie_Powell @jneilliii Thank you for your answers! My original question came mainly from ignorance and laziness.

First I did an image of the previous installation and then flashed the new 1.9.1 with the new camera stack. I went from OctoPi 0.17.0 to 1.0.0 lmao

Now that I went through the process I understand that reinstalling is not as traumatic as I thought. The backup restore is really good and it reinstalls all the Plugins with their settings as they were, so it's really not that big of a deal to reinstall regularly. :slight_smile:

Knowing this I'll definitely update OctoPi more often!

Not sure if new image reports usage. Wanted to share that all is working fine with RPi4 with a pi camera and an USB camera.

There was one comment in the FAQ that might need to be updated. It says:

The configuration shipped on the image will support running either a libcamera device or a USB camera device. To support multiple cameras ...

so I was expecting to have to follow steps in that section to have both cameras running. I was pleasantly surprised when things just worked. :slight_smile: I configured each .conf file and voila!

Great job everyone that was involved!!! When I have more time, I will test in my other RPi that has 2 USB cameras and no pi camera to see how things go.

Gaston

Coming from Obico's OrangePi Zero 2 Image, just imaging is not yet an option (as Obico did not update the image yet) and is not the most practical one, as I for example use RedHat cockpit to manage updates, SMB access, AD join and more that would need additional backups.

I tried downloading and installing with dpkg but it fails

orangepi@beyla:~$ sudo dpkg -D2000 --log=./log.txt -i ./camera-streamer_0.2.transitional_armhf.deb
dpkg-deb: error: './camera-streamer_0.2.transitional_armhf.deb' is not a Debian format archive
dpkg: error processing archive ./camera-streamer_0.2.transitional_armhf.deb (--install):
 dpkg-deb --control subprocess returned error exit status 2
Errors were encountered while processing:
 ./camera-streamer_0.2.transitional_armhf.deb

I added the repo

curl -s --compressed "https://apt.octoprint.org/octoprint.gpg.key" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/octoprint.gpg > /dev/null
sudo curl -s --compressed -o /etc/apt/sources.list.d/octoprint.list "https://apt.octoprint.org/octoprint-bullseye-rpi.list"
sudo apt update

but it seems not to be available for armhf
when I try to install it with sudo apt install camera-streamer-stack

N: Skipping acquire of configured file 'rpi/binary-arm64/Packages' as repository 'https://apt.octoprint.org/debian bullseye InRelease' doesn't support architecture 'arm64'

Even though Gina mentioned explicitly she does not want to support manual upgrading, I am curious. Anyone else out there who wants to start the journey?

Gina's end goal is to have it pulled directly from camera-streamer. I suspect it just doesn't have 64bit builds because the OctoPi image with camera-streamer is explicitly 32bit platform. I think I saw mention on Discord with others that this would probably expand, but why not just grab camera-streamer directly if you want to attempt to use it?

This whole situation is just infuriating

1 Like

Continuing the discussion from A new camera stack for OctoPi:

I sympathize, but I think the frustration is misdirected and the fault lies with the Raspberry Pi people.

Several months ago, I decided to try and solve this myself. I thought I'll build a bog standard Pi using the latest 64-bit PiOS Lite and then run the docker container version of OctoPi under that. I'd use the base OS with the updated camera stack to stream the camera (Camera Module 3) and consume the stream inside the OctoPi container. Months of rabbet-holes later, I have a lovely Pi 4 with CasaOS running containers with OctoPi, Portainer, NodeRED, Grafana, Mosquitto MQTT and a CircuitPython container interfacing some I2C peripherals with MQTT.

All works marvelously. Except the sodding camera!

This morning I set out to install the camera streamer. I thought I'd just type:

libcamera-hello --list-cameras
libcamera-vid -t 0 --inline --listen -o tcp://0.0.0.0:8554

Per the Raspberry Pi documentation. This seemed to work, but the plugin settings in Octoprint will not accept a URL with a TCP protocol, only HTTP. Presumably a web page with the stream embedded. I've watched dozens of YouTube videos and searched hundreds of web sites of Pi fans. I found a few web interfaces using the old stack but not a one claiming compatibility with the new. It seems in Python you have to substitute 'picamera' library with 'picamera2'. That sounds like yet another rabbet hole, and probably a particularly knarly one or someone would have done it already!

I know I should just throw in the hat and buy a Camera Module 2, but my personality means I can't see a brick wall without banging my head on it. Repeatedly!

This project uses camera-streamer to do the streaming - it should be setup by default, and is definitely compatible with libcamera - that's the point of it. You shouldn't need to run these commands to get it to stream.

If you are having issues it's probably easier to open your own topic in the community forum here and provide a systeminfo bundle.

Edited: I have just reread - I think you may be confused between OctoPi, OctoPrint & the new camera stack this blog post refers to. OctoPi is the OS image for Raspberry Pis that comes pre installed with OctoPrint & the streaming setup. The new camera stack in this blog post is only available on the OctoPi image. You aren't using OctoPi, because you are running a different base OS with OctoPrint in a container. If you want streaming, then yeah you'd have to install something yourself. Camera-streamer may still work for you but you'll have to set it up yourself in your setup, and this blog post is irrelevant to you.

Yes, the OctoPi does not really suit my use even though I will run OctoPrint on a Pi. I want OctoPrint to be a component in a wider system and not to entirely replace everything on the Pi. To that end I was looking for a Camera Module 3 compatible web streamer which I hoped to find in the Raspberry Pi ecosystem since it is not really OctoPrint specific. The subject of this thread is actually the closest I've found anywhere in the ecosystem, and it seems like all the good work that has been done could have a much wider audience than just OctoPi. If the streamer was presented as a separate installer, or just a comprehensive installation guide like Gina's for OctoPrint itself, it could be the basis for building OctoPi and also a separate Docker Image with just the streamer, and an optional add-on for those building their own installation. Within the OctoPrint use case, I can see scenarios were the user would want the camera streamer and OctoPrint on different machines or containers. The icing on the cake, it would also be valuable for Pi users who are not even interested in 3D printing! I'll work it out myself if necessary, but looking at the Git repository it seems to be a serious rabbet hole and a lot more complex than I'd expected it to be. I guess I was hoping for a bit of a leg-up from those who have already suffered!

Have you tried camera-streamer? It is an independent project that is being used by OctoPrint on the OctoPi images. It has full support for the CSI cameras.

Another possibility is ustreamer. It appears to have support for the Raspberry Pi cameras as well.

Yea, looked at camera-streamer both the upstream version and in the OctoPi branch. It seems to be a major project to integrate and I wanted to avoid that work if there was an easier option (like a docker image or a single command installer script). The amount of work Gina has put in, and the length of time it's been in beta, suggests using the unstream version is far from straightforward.

It is not enough just to support CSI. The Pi people made a huge breaking change to CSI camera support. For a time, they had 'legacy support', then earlier this year they released the Camera Module 3 which does not work in legacy mode. That broke a lot of older camera software. Thanks for the ustreamer tip. It does look like it might support the new cameras, but it does not look much easier to work with than camera-streamer.

I'm willing to get into cloning from Git and compiling if forced to, but from experience it always ends up being at least a days frustrating work and with a 50% success probability at best!

restreamer maybe, I've used it in with OctoPrint with some success for both directly attached cameras and rtsp cameras.

You don't have to compile anything, and there's example service files that come with camera-streamer. I don't think it should be that difficult to install yourself based on the instructions available.

And just to chime in on this - remember that I have to create a setup that works out of the box, ideally without any human intervention necessary (think config files) for the majority of people out there, including error resilience (e.g. someone just plugged the USB camera out and back in, things should recover) and ease of config if needed (read: config files available on boot partition that can be accessed in thumb stick mode, everything bootstrapped based on those).

Your run of the mill manual install doesn't need any of that, you set up things ONCE for YOUR particular setup and that's it.

However, things would probably be no longer in beta if we didn't have seen some stability issues with camera-streamer:

If you don't access the stream within an hour or so after starting the webcam server, it seems to enter a weird state, and that's a bit of a show stopper. So while that's being worked on upstream, things will stay in beta.

Just an FYI, this new Camera Stack branch of OctoPi did not work with my camera. This was on a Raspberry Pi 3B+ and the camera is an Arducam 5MP OV5647 Camera Module with Motorized IR-CUT Filter.

This setup worked fine with an older version of OctoPi, and still works with the newest OctoPi branch without the new camera stack.

When I first installed the new branch with the new camera stack, this camera worked for a few minutes, but it kept freezing and locking up the image. Then after a few minutes it just completely stopped showing any image whatsoever from the camera. The motorized IR cut continued to work though (I could hear it clicking when I sent the command to toggle the IR cut filter).

At first when it quit working entirely I thought maybe I had damaged the ribbon cable when I was working on the printer (removing the Pi board to access the SD card to upgrade the system to the newest branch), so I ordered a new cable, but that didn't fix it.

Once I went back and installed the newest version of OctoPi WITHOUT the new camera branch, it started working just fine again.

If you are willing to help, provide details regarding "did not work", i.e. a systeminfo bundle and any other details. It would ultimately benefit the entire OctoPrint community. If possible, use a second microSD card so you can easily switch.

Ok will do. Give me a few days and ill get back here with a systeminfo upload. Just waiting on a MicroSD card extension cable to arrive, as my Pi is installed inside my ender 3 and requires tearing apart the machine to access the sd card in the Pi to swap it each time and then reinstalling all the parts to test it. So I ordered a MicroSD card extension cable to relocate the card slot outside to make things easier from now on.

Ok, I've reinstalled the New Camera Stack version of Ocroprint and I've attached a systeminfo bundle to this post. This was taken immediately after installing the new version and restoring my backup.

The camera has not completely quit working yet like it did last time, but it is glitching out right away like it did last time. Here is a short YouTube clip of the glitching webcam stream so you can see what I mean by glitching: https://youtu.be/rFi8g9GJ6qk

Again, for reference, this camera is the Arducam 5MP OV5647 Camera Module with Motorized IR-CUT Filter.

I will continue running this build of Octoprint for a while and upload another systeminfo bundle when/if the camera completely stops working again on this build.

octoprint-systeminfo-20231102183106.zip (20.8 KB)

curious if you've adjusted the width and height to the maximum available your camera is able to produce (2592x1944)? might need to play around with the OPTIONS='--camera-options="AfMode=2" --camera-options="AfRange=2"' part too. Looking at notes for libcamera on the camera-streamer docs...

  • for libcamera the --camera-type=libcamera --camera-format=YUYV (better image quality) or --camera-format=YUV420 (better performance)

I apologize if the question has already been asked but is it possible to somehow enable the features relating to libcamera in an existing installation of Octoprint (installed by hand on a raspberry)?