Octoprint + RPi5 + Pi Camera v3

sudo service go2rtc status
● go2rtc.service - go2rtc
     Loaded: loaded (/etc/systemd/system/go2rtc.service; enabled; preset: enabled)
     Active: active (running) since Wed 2025-03-05 20:13:35 PST; 30min ago
   Main PID: 633 (go2rtc_linux_ar)
      Tasks: 1 (limit: 9258)
        CPU: 30min 34.624s
     CGroup: /system.slice/go2rtc.service
             └─633 /home/M1TT1NS/go2rtc_linux_arm -config /home/M1TT1NS/go2rtc.yaml

Mar 05 20:13:35 Pi5 systemd[1]: Started go2rtc.service - go2rtc.

Well that seems like it's running. You should be able to open http://:1984 to load it's web interface.

With the pi5 there are 2 places to attach the camera. Do I need to designate one of them? If so, where/how?

I have had the camera running in the browser with raspiCamSrv. But couldn't get it to load inside OctoPrint. And the UI is a usability engineer's nightmare.

Why do your questions bounce around so much? Why try other things when attempting to get one thing to work? If you have installed other stuff that takes control of the camera then you probably are running into resource contention issues. Only one software at a time can take control of a camera, etc.

Why do I bounce around so much? I've confirmed the service is running. I already know that I'm not getting anything sent to http://address:1984. So I'm trying to find anything that might be preventing my Pi from streaming video in OctoPrint.
My attempt with raspiCamSrv was on a different build before I flattened the drive to reinstall and try again so the struggles I'm having with go2rtc are on a clean install. I'm still grabbing at straws.

ok, let me back-track then for additional information. sorry the addition of extra information that was from other tests confused me where you were.

  1. what base OS did you install?
  2. was it 32bit or 64bit?
  3. not sure if it matters, but the service file indicates you are probably running the 32bit version of go2rtc based on the name go2rtc_linux_arm?
  4. what does your /home/M1TT1NS/go2rtc.yaml file look like or did it not get created when starting the service?
  5. what does the command sudo netstat -tulpn | grep LISTEN return?

Relative to why a webcam won't load inside OctoPrint depends on the streamer. Since you aren't able to access go2rtc web interface directly, than I would expect it to not work inside OctoPrint. As for other solutions, the best way to debug that is to look at the browser's developer tools to see if there are any additional errors related to connections, etc.

Fair to ask for the details I should have started with:

Linux Pi5 6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt3 (2024-10-08)  aarch64
OctoPrint version : 1.10.3
OctoPi version    : 1.1.0

My go2rtc.yaml file was not created so I had to create it and may not have everything it needs:

picam_h264:
    - exec:libcamera-vid -t 0 --libav-format h264 -o -
  usbcam_h264:
   - ffmpeg:device?video=/dev/video8&input_format=yuyv422&video_size=1280x720#video=h264#hardware

sudo netstat -tulpn | grep LISTEN returns

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      861/sshd: /usr/sbin
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      843/cupsd         
tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN      670/python        
tcp6       0      0 :::80                   :::*                    LISTEN      1018/haproxy      
tcp6       0      0 :::22                   :::*                    LISTEN      861/sshd: /usr/sbin
tcp6       0      0 :::443                  :::*                    LISTEN      1018/haproxy      
tcp6       0      0 ::1:631                 :::*                    LISTEN      843/cupsd

I want to say thank you again for helping me out with this!

ok, I think this might be why it's not working (the netstat command tells me no listening 1984 port).

try this.

sudo service go2rtc stop
wget https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_arm64
chmod +x ./go2rtc_linux_arm64
sudo nano /etc/systemd/system/go2rtc.service

change the ExecStart line to be like this.

ExecStart=/home/pi/go2rtc_linux_arm64 -config /home/M1TT1NS/go2rtc.yaml

ctrl+s to save, ctrl+x to exit.

sudo systemctl daemon-reload
sudo service go2rtc start

if that doesn't work, just try running ./go2rtc_linux_arm64 manually and see what it says or see if it loads.

Woot! I got the service detected on the network!
Next problem:
mse: streams: exec/pipe: EOF
ERROR: *** unrecognized option '--libav-format'***

I'm still going to call this progress.
I'm wondering if this is because pi5 has no hardware support for video encoding.

possibly. what does libcamera-vid --help indicate as available options?

you might need to run some other OS system dependency installs if running lite pi os, check this comment.

Basically run these commands.

sudo apt update && apt upgrade -y 

sudo apt remove rpicam-apps-lite
sudo apt install rpicam-apps --no-install-recommends

I've got streaming video in the browser!
Libcamera-vid --help got me a wall of options. Probably a lot more than you want me to post here.
Running the update threw a couple of errors related to being unable to unlock a couple of files. Unfortunately I cannot retrieve that message since I also did the

sudo apt remove rpicam-apps-lite
sudo apt install rpicam-apps --no-install-recommends

Then reboot and I have video. I just need to get it to work inside OctoPrint now. Classic and RTC options remains dark. I copied the URLs from the http://address:1984/links.html?src=picam_h264 into OctoPrint's Classic Webcam module's Stream & Snapshot fields. But nothing comes up.

You have two options now that you have the application working. You can install my go2rtc plugin and it should be able to read your config, and just work. or you can use the HLS link from the links page of go2rtc's web admin interface in the classic webcam plugin settings.

The plugin which wasn't working before now tells me I need to activate the API in the go2rtc config file, which I assume is the go2rtc.yaml file. It offered to do that itself but fails to do so (probably looking for /pi as the username. So I opened up go2rtc.yaml and added

> api:
>   origin: '*'

The results in OctoPrint changed to:


That list of streams is dozens long and I'm not sure if I would add any of them.
The stream.m3u8 modern HLS/fMP4 link works in Classic Webcam with about an 8 second delay. Too bad the PiCam_h264 doesn't seem to work in OctoPrint since it seems speedier and more efficient.
@jneilliii you've been incredibly helpful! Unless you have ideas on how to get PiCam_h264 running, I'm happy with my current camera situation. :yum:

Now that the plugin sees the server properly, restart OctoPrint and you should have a new camera for each configured one in go2rtc. Hover over camera view in control tab and the additional cameras show as selectable from a list.

Yes. Indeed.
Success!

And if you disable classic webcam plugin, you'll only have the ones from the go2rtc plugin.