Introduction: Raspberry Pi Remote Webcam

Picture of Raspberry Pi Remote Webcam

This will allow you to create a remote webcam for your Raspberry Pi so that you can view it from any computer on the local network. For this instructable you will need:

• Raspberry Pi with an Whezzy Raspbian installed and internet connection established
• Webcam (I use PS3 Eye Camera, but it will work with most USB webcams)
• IP address on your local network (this can be found with the command $ ifconfig and should be something like: 192.168.1.105)

Step 1: Getting Started

Picture of Getting Started

Run up your Raspberry Pi to the command prompt

Install the webcam server software using the following command:
$ sudo apt-get install motion

This will take a few minutes to download and install but once it has finished and takes you back to the command prompt we are ready to continue.

Step 2: Configure the Software

Picture of Configure the Software

Next we need to edit some of the config files so that the motion service will start on run up and be available on local network.

First we will edit the motion.conf file by typing:
$ sudo nano /etc/motion/motion.conf

This is quite a large conf file but the points you need to edit are:
DAEMON = OFF (change to ON)
Webcam_localhost = ON (Change to OFF)

Step 3: Set the Service Up

Picture of Set the Service Up

Next we need to enable the Daemon (service):
$ sudo nano /etc/default/motion

start_motion_daemon = no (change to yes)

Step 4: Start Her Up :)

Picture of Start Her Up :)

Ensure your webcam is plugged into the usb port on your Raspberry Pi and start the service:
$ sudo service motion start

If you want to stop the service then use the command:
$ sudo service motion stop

 With the service started you can now open a webpage on your normal computer and by going to the IP of the Raspberry pi on port 8081 (in the address bar) you should be able to view your webcam (please note that the one in the picture shows port 8089 as I have set this up in the conf file. The default port is 8081): 192.168.1.105:8081

I hope you have enjoyed this instructable and in the near future I will do a guide to allow you to view your webcam over the internet. The reason I have this is so I can connect my webcam to the eye piece of my telescope and transmit my astroviews over the web so friends and family can see the galaxy.

Comments

KaisarK3 (author)2017-09-29

Linux Motion is cool. Also, check out the RPI-Cam-Web Interface project when you get a chance: https://elinux.org/RPi-Cam-Web-Interface

redtahr made it! (author)2017-07-26

cheers for the concise write up. (motions not running in the attached pic, for those who wonder why the led on the logitech webcam isn't lit)

ironmanx46 (author)2017-05-27

Hi, this is interesting and working but I want to edit the motion softwares index file where you see the image output. How to do that?

BrianK50 (author)2015-10-12

For the life of me I can not get this to work. I have followed the instructions to a T.. I have a logitech c310 which I see in lsusb so I know it's there. I finish the instructions and run sudo service motion start.... nothing happens. I figure maybe I should reboot the pi. It comes back up.. and the daemon appears to kick in.. lights on the cam!!! ...then a few seconds after the raspberry is back up and again nothing. sudo service motion start yields no results. I have the files edited correctly, and even turned localhost off for both streaming and management but 8080 and 8081 show nothing. Help? Other options?

RicardoA63 (author)BrianK502016-02-06

Hi! I had the same problem and, like others in this thread, noticed that the webcam turned off when motion was detected. The motion config file is set to save pictures when motion is detected. Since I didn't want to store photos nor videos, I disabled these options by setting output_pictures off and ffmpeg_output_movies off in the config file. This allowed the camera to stream without a problem. Jarrad's solution to give permissions to the directory would probably work if you wanted to store pics/videos.

taung3 (author)RicardoA632017-04-11

Thanks Ricardo. I've been going through so many pages for the past hour because the webcam stopped streaming after a few seconds. Your fix is working for me. And what JarradD2 below said made sense. "Motion" module doesn't have permission to save photos/videos. I don't know how to give permission so I'm following your route.

Folks, if you want this to work, make sure you got the following settings correct for /etc/motion/motion.conf:
output_pictures off (default on)
ffmpeg_output_movies off (default on)
stream_localhost off
daemon on
stream_maxrate 100
framerate 100
weight xxx
height xxx

webcam_localhost is an outdated variable. The new one is now called stream_localhost

taung3 (author)taung32017-04-11

*width

MateuszM11 (author)RicardoA632016-05-13

That works perffect for me thanks :)

Enomaly (author)BrianK502016-08-12

I think motion is crashing right after it starts- mabe something in your config doesn't match the webcam, like the resolution (called width and height).

I have a Logitech c310 and I know it does work also maybe try reinstalling motion after an "apt-get update"

SteveP52 (author)BrianK502016-01-25

I had a similar problem until I placed the camera in a position where there was no motion for it to detect. I'm thinking the motion detection is too resource hungry for the Pi?

JarradD2 (author)SteveP522016-02-03

Got it going on mine, you need to make sure it has permissions for the directory where it saves the photos/videos. I found this out in the syslog. And make sure you have ffmpeg installed

nodislike made it! (author)2017-01-18

Works like a charm! <3 I configured the "motion.conf" and set the "stream_maxrate" to 30 fps which works very good! If you also want a password, just search for "auth" and remove the ";" sign and set the "username:password" to whatever you'd like! I added an image to show you the setup, but it's very blurry.

NaufalS1 (author)nodislike2017-04-08

hello. Sir please help me, how give a password in motion ? I try but it's not work

nodislike (author)nodislike2017-01-18

Not sure why the image decided to flip upside-down, but w/e

gou123456789 (author)2017-04-03

how do i delete a write protected directory in rpi?

Pale Rider (author)2017-01-27

Might I add a suggestion. I did not see it in the comments, but I have found it best to open the stream in VLC Media Player rather than a browser window. A browser window always lead to the eventual stoppage of the stream and the browser displaying a still image of the last frame captured. Using VLC to capture and display the stream eliminates this problem

Mjan456 (author)2016-08-20

One cool thing you can do with the remote camera is view it from your iPhone

just enter the IP and port in safari rather than on your pc or mac

gibson84 (author)Mjan4562016-09-09

Got mine working, but on iPhone the video shows, then disappears and the page just keeps loading - does yours continue to stream?

RinusR (author)2016-08-28

I would like to build a super 8 to digital movie converter from a Raspberry Pi. It should work by taking a picture from every frame by using a LED light source and a opto coupler to indicate the frame position. Has anyone already build this? If not, does anyone know how to trigger the shutter and save the image at a rate of preferably more than 24 fps?

faridraspi (author)2015-10-15

My camera LED comes on after entering the command sudo service motion start however after a few seconds it goes off. Also not able to reach IP address:8080? Any thoughts please?

Enomaly (author)faridraspi2016-08-12

maybe motion is crashing. try reinstalling after apt-get update and going through the config file to see if there are any incompatible settings. also, make sure you have an adequate power supply (2 amp instead of 1 is probably better)I could be totlally wrong I am in no way an expert at this so I may be wrong

faridraspi (author)faridraspi2015-10-15

I was able to keep the camera LED on longer by connecting to Ethernet as oppose to WIFI but still not able to reach via either explorer or firefox. Is there a way to see the streaming video on the Raspberry Pi it self to eliminate the network as a possible issue? I did open a port under NAT/Gaming, range 8080 - 8082...base port 8081 TCP/UDP

SteveP52 (author)faridraspi2016-01-25

To view locally use a URL of localhost or 127.0.0.1 follower by':8080'. E.g. http://127.0.0.1:8080

gavinstokes (author)2016-04-16

Hi

I cant find a line called Webcam_Localhost

Enomaly (author)gavinstokes2016-08-12

i believe its now under a different name. try searching for just local host or just scrolling till you find it. I may be wrong but I think its just called stream_localhost

Enomaly (author)Enomaly2016-08-12

sorry, didnt realize u got answered...

MateuszM11 (author)gavinstokes2016-05-13

Try type "stream" instead "Webcam" That should help. "stream_Localhost"

gavinstokes (author)MateuszM112016-05-15

Its there alight although I have problems finding every time for some reason

StefanoD1 (author)gavinstokes2016-04-19

Me too, please help

MateuszM11 (author)StefanoD12016-05-13

Try type "stream" instead "Webcam" That should help. "stream_Localhost"

mbdmbd (author)StefanoD12016-05-02

Hi - I couldn't find that line either. I was using 'jessie' on an RPi model 1 as my base operating system. Installing motion on this didn't seem to give me the correct settings in motion.conf.

I reinstalled with 'wheezy' version of Raspian, then installed motion..... and there they all were. It might have just been the re-install..... but I'm betting it was the version of motion that wheezy pulled in that solved the problem.

mbdmbd (author)gavinstokes2016-05-02

Hi - I couldn't find that line either. I was using 'jessie' on an RPi model 1 as my base operating system. Installing motion on this didn't seem to give me the correct settings in motion.conf.

I reinstalled with 'wheezy' version of Raspian, then installed motion..... and there they all were. It might have just been the re-install..... but I'm betting it was the version of motion that wheezy pulled in that solved the problem.

MarkoP4 (author)2016-05-24

Thank you. A bit of configuration needed to disable only localhost streaming:
stream_localhost false

AnnaMai (author)2016-05-11

easy to make camera usb view via LAN network/ internet

http://engineer2you.blogspot.com/2016/05/raspberry-local-ip-webcam-usb.html

bruster999 (author)2016-04-06

Thanks for the great Instructable. It works perfectly!

Is there a way I can add more information to the web page? I have a temp sensor and would like to have the data displayed on the same page.

Bruster

LanceD8 (author)2016-02-26

So I can connect to it through port 8080, but there is no video feed, just a screen that says

Motion 3.2.12+git20140228 Running [1] Threads

All

When I click on the ALL, it shows another blank screen that says

<– back


Thread 0

config

action

detection

track

None of these links has a video feed in them.

Any ideas?

OrlandoB9 (author)LanceD82016-03-30

try port 8081

t0mm0t (author)LanceD82016-03-14

that's the webcontrol interface. check the settings in the motion.conf file in section "HTTP Based Control".

BTW: standard port for the video is port 8081, not 8080. maybe it's just that?! if not contact me, i think we can figure that problem out quickly...

LanceD8 (author)LanceD82016-02-26

And by "blank screen" I just mean it doesn't have anything else other than the text and links: no images, no video, nothing.

amihell (author)2016-03-30

hey

I have set everything up but don't know how to actually view the camera

I'm new to this so please help

OrlandoB9 (author)amihell2016-03-30

open webbrowser and enter hostip:8081

DeepikaJ3 (author)2016-03-10

Can anyone explain in detail or provide me the link where i can read what does 'motion' software do?

jrmacho22 made it! (author)2015-11-18

Swweeeet it work for me!!! had do a few tweaks as other suggested in the comments! it would start then die after a few seconds, changed the frame rate etc.

Thanks!! :) now on to streaming this to remote site.

Thanks

AlexB32 (author)2015-11-18

Hi Guys, I got it to work, but it only works for so long and then I have to type "sudo service motion restart" it will then work for another minute or so? Any ideas?

Also, its quite blury with movement, will that be the limitation of the pi or webcam?

MEGHAP4 (author)2015-09-25

is it necessary to have a proxy server to view the video on local network/

InamR (author)MEGHAP42015-11-13

have u done ur project ?? I am doing something similar 'll u help me a little ?

MEGHAP4 (author)InamR2015-11-13

Not yet ....will be starting it soon

FabioB3 (author)2015-10-31

Great instruction! A tip for anyone who wants to increase the framerate of the streaming is to set the fps to the parameter "webcam_maxrate=xx" in the motion.conf file where XX is the desired frames per second. By default the framerate is 1 fps which gives a bad streaming experience. Unfortunately this parameter is frequently forgoten in most tutorials. 15 fps is working fine for me.

MEGHAP4 (author)2015-09-25

i have my final year project ....i want to stream live videos from a simple webcam connect to my raspberry pi ,it should give me a push up notification on my smart phone and then the video streaming should get started...how it will be get done?

sendaljepits (author)2015-09-13

good jobs,,working for me,,TY

About This Instructable

531,421views

452favorites

License:

Add instructable to: