Random printer stutters with 720p webcam enabled

Camera model


root@orangepilite:~# sudo v4l2-ctl -d /dev/video0 -L
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=50 step=1 default=0 value=0
saturation 0x00980902 (int) : min=0 max=100 step=1 default=55 value=55
hue 0x00980903 (int) : min=-100 max=100 step=1 default=0 value=0
white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=100 max=300 step=1 default=100 value=100
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=10 default=4500 value=4500 flags=inactive
sharpness 0x0098091b (int) : min=0 max=10 step=1 default=2 value=2
backlight_compensation 0x0098091c (int) : min=0 max=4 step=1 default=1 value=1
exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=1
1: Manual Mode
3: Aperture Priority Mode
exposure_absolute 0x009a0902 (int) : min=5 max=10000 step=1 default=166 value=300

root@orangepilite:~# v4l2-ctl --list-formats
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Index : 1
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : Motion-JPEG

Additional information about your setup (OctoPrint version, OctoPi version, ...)
HW: OrangePi Lite
OS: Ubuntu Bionic with Armbian Linux 4.19.57-sunxi
Octoprint ver: 1.3.11
Timelapse: every 10 seconds. (even happens without timelapse)

mjpg streamer:

/usr/local/bin/mjpg_streamer -i "input_uvc.so -r 1280x720 -d /dev/video0 -q 80 -ex 500" -o "output_http.so -p 8080 -w /usr/local/share/mjpg-streamer/www"

I've used this tutorial to install Octoprint and webcam:

What is the problem?
Printer stutters in random parts of print, CPU usage goes to 100%. Sometimes the printer stutters for 2 seconds, it seems random.

What did you already try to solve it?
Disabled the webcam, lowering frame rate, lowering quality

Logs (/var/log/webcamd.log, syslog, dmesg, ...)
octoprint (3).log (234.3 KB) serial (1).log (3.7 MB)
Image album with htop while webcam is on (there seems to be desync with graphs, so the 3 first screenshots have graphs where usage is at 100% and the next 3 have the task list when it's at 100%):

htop without webcam:

I have no clue about linux, and how to use it, I'm just following the tutorials.

Note that the OrangePi Lite has 512MB RAM as compared to the Raspberry Pi 3B, for what it's worth.

I can see from the htop output that OctoPrint's nice attribute is -2. Did someone suggest that you should change this? Anything negative implies "give this more priority". And if you did try to adjust it, you should do this under the root user (sudo) rather than yourself.

If you did want to step on the mjpg_streamer to give OctoPrint some breathing room, you'd want to +1 some nice to that one rather than trying to adjust OctoPrint, at least IMHO.

I have no clue what "nice" is, I didn't change anything. This is how it came out of box.

After some reading, should I change


or is there a better way?

nice is a Linux command which will adjust a process so that it runs at less priority, allowing other things to have more. It's possible that while in htop you press a combination of keys to adjust the priority of OctoPrint during that session. I wouldn't focus on that now, to be honest. I just thought you might have changed something as part of that tutorial you'd read from.

It's possible that you shouldn't be trying to do videos on this platform and that's just how it is, given the platform.

My octoprint is also on -2 out of the box

1 Like

Previously I used Logi 270C cam but the quality was horrendeous, and it worked, I don't want to drop the resolution to make it work. I could live even with 1 frame per 5 seconds or something like that as long as the resolution is 1280×720

So I guess you tried 1 fps framerate already and the cpu is still at 100%?

Btw have you tried to put a fan on it? Maybe something throttles or gets instable and that's why it's stuttering

If it were me, I'd outsource the problem to another Pi.

1 Like

It's not always on 100%, it is sometimes (seemingly randomly) going 100% and printer stutters, sometimes it stutters 10 times in 1 minute, sometimes it stutters once in minute. It doesn't matter if timelapse with ffmpeg is enabled or not, the webcam service just needs to be on.

I have fan on the cpu, without it, it says 43°C, with it 23°C.

Hmm, interesting idea, but I'd need the Zero W that is the same cost as the Orange Pi lite. Zero W is almost twice as expensive in my country as the standard one (7$ vs 14$), instead I think it's just better to buy the 3B+, I thought that I could make it work with the Pi Lite, it seems perfect for the job.

If you're very handy, you could use the Pi Zero (no W) and configure it in network gadget mode, plugging it in and powering it via the main computer which runs OctoPrint. It presents itself as a private network like 192.168.4.x. The price here is $5 for that one. But then again, you'd need to deal with the increased current for the main power adapter.

I don't know too much about SBCs, only AVRs, even less about linux and it's derivatives.

I think that's neat idea, but would that work with armbian that OPi that uses? If so, I think I will go that route, I have 12V 2A power supply and then DC buck converter for 5V, if that is not enough for both I could just add another buck for the Zero.

I still would like to know why CPU load jumps to 100% even if webcam is turned on, but not used.

Honestly, I don't recall mjpg_streamer by itself causing 100% usage to a core. What does peg the CPU core is visiting the OctoPrint web page interface, though.

I talk about building a gadget-mode Pi Zero here, for what it's worth. You could ignore most of that talk about DNS.

I've tried lowering the resolution to 800x448, and it's super random when the printer stutters, yesterday had almost no problems with 850x478, but lowered it just to be safe and first 2 layers almost perfect then it goes to 3rd one and it stutters for like 3 minutes every second, sometimes stopping for 10 seconds doing nothing, and then again perfect for minute. I'd like to understand what is happening. I'm not looking at the web interface and am not connected via ssh to have the best performance, the heatsink is barely warm.

I think I will try to sell my OPi lite and get the 3B+. Though I can't find any info about 3B+ mjpg streamer capabilites, if it can handle the 720p or 1080p stream.

When you run htop, toggle it with by pressing capital H so that it squashes the multiple lines together. It's then easier to see what you're working with. Make sure that you can see both OctoPrint and mjpg_streamer at the same time and watch from another console.

Honestly, this feels like your slicing may include too many tiny segments for circular features. Try adjusting this on the slicing side of things. This would imply that too many movements are queuing up in the controller's receive buffer and it fills up. It would then send a busy to OctoPrint and it would sit there quietly waiting until the controller is ready again.

In other words, turn on the serial.log in OctoPrint and review it.

If it were me, I'd create the same sliced job but just limit the height to fifteen layers. Or I'd just abort after the first five were observed each time.