Camera-streamer configuration on the new camera stack for OctoPi

Great I'm up and running with @Charlie_Powell's plugin! It just worked!

Now to figure out how to tell camera streamer to send the raw 1080p h264 stream without re-encoding it. Looks like right now it's consuming ~36.1% CPU at 720p so theres very likely transcoding happening (though probably openmax accelerated at least).

@johnboiles

It does not re-encode. The WebRTC when running does require encrypting the stream in transit. This depending on device costs between 20-40% of a single CPU core.

All available configs can be found here: libcamera/control_ids.yaml at 06bbff9c23d5a85acd65595216c6b75094891f72 · raspberrypi/libcamera · GitHub.

The develop branch changes those value to human readable, it will at some point land in main, alongside some web interface to modify settings live.

  • CSI/USB: NBUFS: Number of buffers to use, defaults to 2 if unset.

I think we could fine tune this to 3.

USB: * FORMAT: Image format to set on the camera, defaults to YUYV.

My advise would be to try JPEG. YUYV most of times will overrun USB bus and have quite choppy framerate. Only older cameras do not support JPEG, but the usage of YUYV could be provided as a fallback.

Hi @ayufan! Fantastic work on camera-streamer!!

So by default if my camera can output h264, then it will stream that out directly and it just works?

I've noticed I can run the mjpeg compatibility stream (eg from Cura) at the same time that the h264 WebRTC stream is running (which is really neat). So there must be at least one transcode happening right? Is the mjpeg stream re-encoded from the h264 stream, or is the h264 stream re-encoded from the mjpeg stream? Or are they both encoded from the YUYV stream?

@johnboiles

The h264 stream from cameras is hit-miss, since you cannot force key frames. The only supported captures are: YUYV (and variants), JPEG, RGB, and various raw formats from CSI cameras.

Depending on input format the pipeline differs, at least there always have to be a single encoding block used to encode either JPEG or H264, or sometimes both:

  • YUYV => JPEG | H264
  • JPEG => YUYV => H264
  • RB10 (bayer 01 bit) => via ISP => YUYV => JPEG | H264
  • if downscaling is used it might also trigger: JPEG => YUYV to downscale => JPEG | H264
1 Like

Go further down into the plugins section of settings and check the Classic Webcam settings for those fields.

1 Like

@brentil - as mentioned above already in this topic. If you have issues with setting up the new camera stack, then you must open your own post. It is extremely confusing to have lots of issues all under one thread that is supposed to be a guide to help change the settings in camera streamer.

Congrats @foosel on this new feature. Where can I find instructions for a custom install of OctoPrint (without the RPi imager). I checked this thread and issue 2 for OctoPi-UpToDate but I was unable to find it.

It's the one that has camera-streamer mentioned.

Thanks but I think I wasn't clear. I have reasons why I have a custom installation of OctoPrint without OctoPi. I'm looking for instructions on how to add this new camera stack to a standalone OctoPrint installation (on raspbian) that doesn't use OctoPi.

1 Like

Ah, gotcha. It's using this.

1 Like

The new camera stack is built for OctoPi. If you want a similar thing for yourself, then you have to install camera-streamer yourself - you can't take advantage of the scripts here, they are OctoPi-only. The whole 'new stack' idea is specific to OctoPi as well.

hi i have octoprint installed on raspbian do i need to install the camera stack ?

it says im running Version 1.9.0.
thanks martin

How do I take a snapshot with the new stack? Can it be done both via OctoPrint and the console?

Found it: You have to do http://localhost:8080/?action=snapshot

Is there any camera option for FOV? I have a Logitech Brio that can run at 65°, 78°, and 90° as configured in Logitech software. Looks like its running 65 as default and would love to get the wider view for timelapse if possible.

Gave up, doesn't look like a configurable option and since it's not manual can't open camera up to change it either. Remounted to make it work for now, will probably replace with different model.

If I add an USB camera with add-usb-camera and I choose the right camera and I can see it set port 8082.
is the URL to the stream as it was before http://octopi.local:8082/?action=stream ?
I can't see the video.

I cannot get this to work at all. I did a fresh install of OctoPi 1.0.0 and Octoprint 1.9.2. I have one USB camera attached, and camera-streamer is running:

/usr/bin/camera-streamer --http-port=8080 --camera-type=v4l2 --camera-path=/dev/v4l/by-id/usb-046d_Logitech_Webcam_C930e_3B3BA81E-video-index0 --camera-format=YUYV --camera-width=1280 --camera-height=720 --camera-fps=15 --camera-nbufs=2

However, when I go to 192.168.1.5:8080 or 192.168.1.5:8081, I just get "Unable to connect". What am I missing? lsusb shows the camera just fine. journctl shows:

Sep 11 21:41:00 octopi systemd[1]: Starting camera-streamer...
Sep 11 21:41:00 octopi camera-streamer-control[3486]: Running start for camera-streamer-libcamera.service...
Sep 11 21:41:00 octopi camera-streamer-control[3486]: ... done.
Sep 11 21:41:00 octopi camera-streamer-control[3486]: Running start for camera-streamer-usb-default.path...
Sep 11 21:41:00 octopi camera-streamer-control[3486]: ... done.
Sep 11 21:41:00 octopi systemd[1]: Finished camera-streamer.

Setting this in usb-default.conf fixed it:

OPTIONS="--http-listen=0.0.0.0"

1 Like