Is mjpeg to blame for terrible cam streaming?

When my Pi and my computer are both attached to local ethernet, my webcam streaming is okay. As soon as one is on wifi or I'm remote, I really notice the lag.

I'm guessing the problem is the bandwidth thrown through mjpg_streamer. That's backed up by blog posts such as this; there's a difference between mjpeg and video, most of that comes down to bandwidth (and the obvious CPU tradeoff).

Is this well-trodden ground? I haven't found much other than configuring various webcam sources with mjpg_streamer.

grabbing comments from various github issues.

gina:

Native camera support even among the cheapest of them. Yes, you could just transcode the whole stream of any source format, be it mjpg, single jpgs or h264 and push that out as an mp4 http stream. But then that whole work has to be done by the system's CPU. Which - in case of OctoPrint's common runtime scenario - is severely limited. Transcoding some full-HD MP4 stream is simply a whole lot of computation that needs to be done while also trying to do everything else. So just taking the MJPG stream from the camera that it supports natively and piping that through 1:1 without having to think about it any way is a huge benefit.

that leads into 'iframe camera view' or other replaceable camera tabs. Another request for the same type of thing.

cam-stream is a 'small python hack' to push V4L2 to http via webm or mjpeg.

blog posts/pages:

It seems to be so. The only solution seems to be tweaking the flags when running the mjpeg_streamer command. Finding the sweet spot for your camera, hardware, and network too get the best quality/lowest lag. For instance my lifecam1000 runs okay over wifi with this command.

./mjpg_streamer -i input_uvc.so -d /dev/video0 -y -f 5 -o output_http.so -p 5001 <-w ./www-octopi>

when you do hw encoding a pi2 can handle around 15 FPS @ 1080p

are you streaming it for octoprint? how?

actually i doesn't use a raspberry for productive usage (only for developing stuff) the hw is too bad for the price the power consumption compared to cpu power ...
I didn't test it with octoprint ...

Yes, wifi* sucks for webcam streaming through mjpeg streamer.

*Not all wifi is created equally. You could get a high powered USB dongle that runs higher bandwidth than the built in wifi on a pi3 (non+) or the regularly recommended edimax dongle.

I had much greater success when using a TPLink 5ghz wifi adaptor but it's not supported out of the box and requires either compiling your own drivers, or hoping someone compiled them for you.

It also depends greatly on distance / line of sight to the router. Buried in my print room and the signal sucks, the cam stream is laggy, but if I put the pi next to the router then it's fine (but obviously can't have the printer next to the router). I solved that one by just using a 6m long USB cable and moved the usb dongle out to a better location (6m long and you're gonna need a powered usb cable).