Create a gist now

Instantly share code, notes, and snippets.

@endolith /readme.md
Last active May 17, 2017

What would you like to do?
How to stream a webcam to a web browser in Ubuntu

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion
~> nano ~/.motion/motion.conf

In it, the bare minimum to run a web server and view it on other computers:

webcam_port 8081
webcam_localhost off

Then run motion:

~> motion

Now you can view the webcam at http://hostname:8081 If it doesn't work, try rebooting between steps or something.

Isn't that easy? >:(

See also: How to run webcam software only when I am not home

This is bloody awesome, thank you!

duramato commented Sep 5, 2015

i cant seem to make it work ,got any clue why?

There is a lot missing from the instructions, like setting the frame rate and other settings in the motion.conf file. There are many good tutorials on setting up motion as a web cam. You should also check that your camera is working, make sure there is a /dev/video0 device (which should be the default for your camera).

Personally I would like to see a change in the motion software to use something other than MJPEG stream compression as it is a bandwidth hog if you want live streaming.

Wow!! That was super easy. Thank you.

Don't forget to apt-get update first or you'll get E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?.

Salgat commented Feb 19, 2017

At least for me with Ubuntu I had to use these config settings

stream_port 8080
stream_localhost off

mlliarm commented Apr 2, 2017 edited

On Lubuntu 16.04 I've used the config settings mentioned by Salgat and it works like a charm.

Thank you.

Hi,
I want to show video from webcam at website with https. How to stream it via https protocol?
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment