Trying to get Octoprint (1.10.0) to work with RPi5 (latest Bookworm, not Octopi) and a Pi Camera v3
What did you already try to solve it?
I tried running camera-server but it appears like it doesn't support the Pi Camera v3 on an RPi5 since the RPi5 dropped h264 hardware encoding.
I was able to make it work in a kludgy fashion by hacking libacamera streaming code in Obico to work with libcamera2. However, support for internal streaming within Obico seems to be going away and my hack is not very stable (the stream crashes after several hours to days).
So, has anybody else succeeded in getting a Pi Camera v3 to work with a RPi5 on Octoprint?
If so, what streaming software are they using?
I did see someone mention raspi-cam-srv as a potential streaming app that works but before I try it, I wanted to see what others are recommending.
you should see if go2rtc gives you any better support. I've used that on a couple of my setups for transcoding rtsp streams, and using locally connected devices. Pretty sure the v3 camera and go2rtc work using an exec stream that points to libcamera.
Edit: the nice thing about go2rtc is that there is lots of support from the Home Assistant community.
So, what do I need to do to get the stream to show up in Octoprint?
Also, is it possible to use a webrtc stream?
If so, what stanzas do I add to go2rtc.yaml to configure the stream and what do I do on the Octoprint side to receive the stream?
I did a fair bit of googling and couldn't find any good examples of using go2rtc with Octoprint which is surprising since this streamer seems to be very powerful and more widely supported than camera-streamer as used by octopi.
I have reconfigured my octopi haproxy setup to redirect /webcam/ to port 1984 instead of 8080 and use the HLS stream url like: /webcam/api/stream.m3u8?src=bambu_camera&mp4=flac.
Pseudo possible with my webcam iframe plugin and the stream url like you mentioned above, but other apps like octoapp won't be able to pick it up. HLS is able to be picked up by OctoApp I've heard.
I just run it and octoprint from my user crontab using '@reboot' that way I don't need to mess with services. Though your service method is simple enough.
Question:
I get that for Pi Camera v3 on an RPi it makes sense to use libavformat h264 since there is no native hardware encoding on the RPi5 (output is RAW10) so might as well encode into h264 which uses less network bandwidth to stream.
But my USB nozzle cam (an endoscope) appears to support MJPG and YUYV (at least those are the two formats listed by v4l2-ctl --device=/dev/video8 --list-formats-ext).
Are those native streams? If so, does it make sense to keep them as mjpg rather than transcoding to h264 (which presumably is not native). So while the network bandwidth will be higher, the software transcoding overhead on my RPi will be less.
you seem competent enough to figure that out with standard linux commands. the streams are only active when you're looking at them so make sure they are active when checking something like htop. the big savings between HLS vs MJPG when viewing is network bandwidth, it's very possible transcoding from native MJPG to HLS is going to consume CPU.
I agree.
But the output of PiCamera 3 per the specs seems to be RAW10 -- not MJPG -- i.e.there is no native MJPG (at least if I am reading the datasheet correctly)
So, it would seem a transcoding would be necessary regardless - whether to MJPG or to HLS.
My thinking is that even if transcoding to HLS is a bit more computationally intensive than to MJPG, since you need to transcode anyway, it would seem that HLS is an overall winner given the lower bandwidth.