How to configure streaming with 1080p 30fps video?

Camera model

eMeet Nova USB Webcam

What is the problem?

I am trying to set up the webcam to run at 1080p 30fps smoothly using the HLS streamer on the latest beta version of Octoprint with the new camera stack.

What did you already try to solve it?

I have gone into the camera-streamer files, octoprint.txt files, and changed any resolution and framerate information I can find to what I need. I have also followed these topics to see if any of the information would help:

Currently trying this

Tried setting up restreamer with docker

I got close with restreamer but could not get the camera feed to start. Might need to do a fresh install on the SD card.

Might be easier to use the new camera-stack as discussed here and use webrtc and this plugin.

I have attempted the new camera stack version and while it had the correct aspect ratio, the resolution and overall quality suffered still even after changing configs. I just attempted setting it up using john's setup here, but it didnt work. I was about to reinstall a fresh image and try again since this one has been beaten on all day trying to get things to work.

Before doing that I will try the new camera stack version again and attempt to use webrtc and the plugin you recommended. I will update with my findings.

Edit: Set up the camera settings config following this post. Despite the setup I am still getting the same low FPS laggy video. My usb-default.conf looks like this:

### Options for USB based cameras

# The port on which the webcam server for the camera should listen on. If you have only
# one camera, leave at 8080. If you have more, change to 8081, 8082, etc. The primary
# camera will be considered the one with 8080.
PORT=8080

# The path to the camera device. Leave as is if you are using no or only one USB camera.
DEVICE=/dev/v4l/by-id/usb-*-video-index0

# The image format of the camera.
FORMAT=YUYV

# The resolution to set on the camera. Defaults to 1280x720.
WIDTH=1920
HEIGHT=1080

# The framerate to set on the camera. Defaults to 15fps.
FRAMERATE=30

# Additional options.
OPTIONS= --camera-options=powerlinefrequency=2 
--camera-video.options=videogopsize=60 
--camera-video.options=videobitratemode=0 
--camera-video.options=videobitrate=4000000

what do you get when you run v4l2-ctl -d /dev/video0 --list-formats-ext

EDIT: quoting the camera-streamer docs on GitHub...

It is advised to always use:

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

I have been reading through that and this post and so far setting the image format to JPEG has fixed the choppy frame issue. I will try the USB camera config you mention above and see what it does.

When I run the v412-ctl command, I get the following:

pi@octopi:~ $ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'MJPG' (Motion-JPEG, compressed)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 960x720
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 864x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1600x896
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1024x576
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 800x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 352x288
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 424x240
                        Interval: Discrete 0.033s (30.000 fps)
        [1]: 'YUYV' (YUYV 4:2:2)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 960x720
                        Interval: Discrete 0.100s (10.000 fps)
                Size: Discrete 864x480
                        Interval: Discrete 0.100s (10.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 800x600
                        Interval: Discrete 0.100s (10.000 fps)
                Size: Discrete 1600x896
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1024x576
                        Interval: Discrete 0.100s (10.000 fps)
                Size: Discrete 800x480
                        Interval: Discrete 0.100s (10.000 fps)
                Size: Discrete 352x288
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 424x240
                        Interval: Discrete 0.033s (30.000 fps)

Reading the documentation shows that the camera resolution should be set to the full resolution of the sensor, then have the specific video/snapshot/stream resolutions be 1080 (or whatever is desired) as to get the best quality. Is there a way to find what the full resolution of the sensor in my camera is? By changing the settings I have set thusfar, the latency is reduced and the framerate is close to 30fps (some stutters though). The last thing that seems to need attention is the image quality, which is most likely to do with the resolution issues I mentioned above.

I would try MJPEG format at 1920x1080, which seems like your largest supported resolution.

EDIT: also the best way to improve some of this would be ethernet and not wifi

That's how I've set it up and it seems that's as good as it's going to get, which I'm happy with. The main thing that helped was changing the image format from YUYV to MJPEG. Fps practically doubled. As far as the connection method, Ethernet wouldn't be feasible in its current location however I could run it on the 5ghz channel and see if it helps at all. The video stream is only 6mb/s so it shouldn't be too big of a burden on my R6700 router.

Interesting development. If I am on my home network and I connect to the Octopi using my external IP (effectively connecting through WAN) its smooth and fine. But when I connected from my phone on 5G full bars it was stuttering and struggling.