How to avoid High CPU usage with YUV webcams

Camera model


What is the problem?

As with many other cameras, this one is only capable of outputting YUV format, and so results in high CPU usage on the SBC.

What did you already try to solve it?

I had a look at this topic: USB webcams known to work with mjpg-streamer
And it recommends using v4l2grab as a workaround high CPU usage but I can't seem to get it to work properly. I mean, the recommendation is this:

Start by calling ./mjpg_streamer -i " -r -d 0 -f /dev/shm" -o "./ -w ./www"; it will display and delete new files. Then, call ./v4l2grab -c -m -q 50 -o "/dev/shm/"; do not forget the trailing / on this command, which continuously captures jpgs of 50% compression without bound.

The first command fails because -r is not given any valid value but I fixed it by specifying 640x480. However, it still fails with this message:

i: init_VideoIn failed

and if I specify /dev/video1 instead of 0 for the -d argument, it works but eats up all CPU and does not give back control to start the second command.
Nevertheless, I stopped mjpg_streamer and ran v4l2grab -c -m -q 50 -d /dev/video1 -o "/dev/shm/" but this too uses a lot of CPU.

I have seen the following thread too: I see high CPU usage when mjpg-streamer is running
As it does not have the above recommendation, I'm wondering if there actually is a solution other than finding a webcam that outputs MJPEG format directly.

Have you tried running in safe mode?


Did running in safe mode solve the problem?


Systeminfo Bundle (7.0 KB)

Additional information about your setup

Octoprint is running on an Orange Pi Lite with Armbian all in their latest versions

Did you stop the webcamd service? Multiple applications can't access the camera at the same time.

sudo service webcamd stop

Thanks for your reply.

Since this running on an orangePi, I'm not using the OctoPi image but an armbian onto which I have installed octoprint.

But you are right, if I run mjpg_streamer and try to start v4l2grab in another console, it complains that the device is busy.

That being said, both of them are using up to 70% of the CPU which is what I'm trying to avoid.

Simple answer is no. YUV is always going to use lots of CPU.

Thanks, that confirms my feeling that the workaround suggested in the first thread is not applicable to my case.

I assume the camera doesn't support mjpg format natively?

Alas, no, only YUYV 4:2:2 is reported by v4l2-ctl