So as per this link but with some condensing and adjustments, first run these commands:
apt-get install git libv4l-dev libjpeg8-dev imagemagick cmake -y
git clone firstname.lastname@example.org:jacksonliam/mjpg-streamer.git ~/mjpg-streamer
make USE_LIBV4L2=true clean all
make DESTDIR=/usr install
Although I'm not sure the last line worked for me, I presume it all worked without it. I think it should have put files in the right places (e.g. so executables do not need full paths specified - so instead in the command below I specified the full paths for all files).
Start the server:
~/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "~/mjpg-streamer/mjpg-streamer-experimental/input_uvc.so -f 15 -r 320x240" -o "~/mjpg-streamer/mjpg-streamer-experimental/output_http.so -p 8090 -w ./www"
And if you're having trouble with something already using the webcam, (e.g. if
motion didn't exit cleanly, do the following and repeat the above command:
which will give output like this:
Then run this to kill whatever's using the webcam:
kill -9 12324
Finally to view the video, navigate to this address, substituting the IP address or URL of your server:
And to embed the video in a webpage, simply add this to the HTML:
As a side note, when running the video streaming server, you might want to change the frames per second by changing the argument after
-f. It seems it has to be a figure that is supported by the webcam; an unsupported figure will in theory be coerced by
mjpeg-streamer to a supported one, but it failed to stream when I set it to
10, for example. The same goes for resolution; only
640x480 worked for me.