Create a gist now

Instantly share code, notes, and snippets.

@endolith /readme.md
Last active Mar 29, 2017

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

@calebunleashed

This is bloody awesome, thank you!

@duramato
duramato commented Sep 5, 2015

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

@Galbi3000

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.

@SushilShrestha

Wow!! That was super easy. Thank you.

@RandomArray

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
Salgat commented Feb 19, 2017

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

stream_port 8080
stream_localhost off

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