Instructables

Raspberry Pi as low-cost HD surveillance camera

FeaturedContest Winner
Picture of Raspberry Pi as low-cost HD surveillance camera
mounted_sm.jpg
IMG_2125_xsm.jpg
This instructable describes how to build a surveillance cam based on a Raspberry Pi micro-computer which records HD video when something moves in the monitored area. Live picture can be viewed from any web browser, even from your mobile while you're on the road.
What you will get:
  • See live stream in any web browser from anywhere
  • Record any motion into video file
Usually, such a cam will cost you around US$1.000, but with the result from this instructable, you will get such a cam for only about US$120.
 
Remove these adsRemove these ads by Signing Up

Step 1: Background

Picture of Background

Have you ever heard of Raspberry Pi? It's a low-cost micro-computer that is able to run Linux and has endless extension possibilities. It cost only about US$35 and opens up endless possibilities of what you can build with it. The official website can be found at http://www.raspberrypi.org/

Step 2: Hardware components

Picture of Hardware components
rasp_cameramodule.png
raspberry_cam_housing.jpg
raspberry_power_supply.jpg
SD-card.jpg
wifi-usb-stick.jpg

We need some hardware for this project. This is a list of the major things we need:

  • Raspberry Pi Model B: This is the larger model of the Raspberry computer system with 700MHz and 512MB Ram. It supports HD video. You can easily order it from i.e. here. Cost: about US$40. You could also use the Raspberry Pi Model A which is slightly cheaper and consumes less energy. Stefan Knight has written an excellent article on how to run this whole project on a model A.
  • A housing for the camera: you don't need to buy a high-price-housing for your Raspberry. There are loads of very cheap fake security cameras available which perfectly fit our needs here. Search the web for "surveillance camera dummy" and you will find loads of housings for your new camera for only a few dollars. I.e. this one will do the job: http://amzn.to/15XLaAj for only US$9. We have ordered this camera housing for about 20€ in Germany that had enough space for all the components:http://amzn.to/19CTEaN. You can use any camera housing, but only be careful about the size of the housing so that the Rasperry board will fit in there. The dimensions of the Raspberry board are 85.6 x 53.98 x 17 mm (approx 3.37 x 2.13 x 0.67 in).
  • Power supply: The Raspberry computer does not come with any power supply, you have to get one on our own. Any power supply with a micro-USB plug can do the job as long as it supplies at least 1A of power. We have ordered such a power supply which already has a micro-USB plug for about US$10
  • SD card: as the Raspberry Pi does not have any storage on board, you need to add some so that you can install and run the operating system for this device. Any SD or microSDHC should do the job, but we recommend using a Class 10 SD card. It's only around US$7
     
  • To connect this cam to your network, you also need some kind of network connection. One possibility is to use a LAN connection, but you would need to put LAN cable to the point where you want to mount the camera. A better alternative is such a WiFi USB adapter for only about US$10
That's all: for about US$120 we have all the hardware we need to build this HD surveillance cam.

Step 3: Install Raspbian

At first, you should install the OS and software to the Raspberry Pi before mounting it all together. An OS is the basic operating system software that tells the Raspberry hardware what to do. Linux is perfect for this. We have chosen Raspbian, as it's one of the most advanced OS for the Raspberry with loads of help and tutorials on the internet.
You need to prepare the SD card to be able to run Raspbian on the Raspberry: this excellent tutorial from Adafruit will explain the necessary steps.
Now temporarily connect your Raspberry Pi board to LAN cable, a monitor (HDMI TV works out of the box, but a HDMI-to-DVI cable like this will do the job as well) and a USB keyboard for the basic setup.
Insert the prepared SD card with the Raspbian installer on it and attach the power supply.
The Raspberry should boot up and guide you through the setup process as explained in this Adafruit tutorial. After this, you should have a basic Raspbian OS running.
Be sure to enable SSH in Raspbian so that you are able to control the Raspberry device also when there is no monitor and keyboard attached. And you should also enable the camera from the Raspbian setup menu so that we can use it for motion detection.
Now make sure your RPI is up to date:

sudo apt-get install rpi-update
sudo rpi-update

And also update all packages:

sudo apt-get update
sudo apt-get upgrade

Step 4: Connect via SSH

Picture of Connect via SSH

Now that the basic setup is done, you should connect to your Raspberry device from your computer. You can connect to Linux console from any computer in your local network and control it like you where sitting directly in front of it. This is very important as once mounted far away from your desktop, you need to be able to make updates and change the configuration of this camera any time later without the need to detaching it from the wall and bringing it back to your desk.

Remember that this cam is not just a dump cam device but a very powerful computer with Linux OS running on it. It's not limited to what we explain in this article now; it will follow any development in software so that you will be able to install updated software and more modules any time later.

First, you need a software to connect to the Linux console on the Raspberry. For Windows, you will need the extra (free) software PuTTY. Download it from the PuTTY website, install it and connect to your Raspberry Pi device:

From now on, you don't need any monitor and keyboard attached to the Raspberry anymore.

Step 5: Enable WiFi

If you want to run this camera with a WiFi USB dongle (like we've suggested in step 2), you will need to do some quick additional steps to make WiFi work on the Raspberry:
From the console (PuTTY window), edit the network properties of the Raspberry:
sudo nano /etc/network/interfaces 
Now add these lines at the end of the file (or change existing lines to match these):
allow-hotplug wlan0 
iface wlan0 inet dhcp 
wpa-ssid "YOUR NETWORK SSID"
wpa-psk "WIFI PASSWORD"
(Fill in the SSID and password for your WiFi network)
Reboot the Raspberry with this command and see if it correctly connects to your WiFi network:
sudo reboot  

Step 6: Put the hardware together

Picture of Put the hardware together
mounted_sm.jpg
IMG_2121_sm.jpg
Now it's time to assemble all the hardware components together into the housing. Depending on the housing, this should not be a too complicated job. Be sure to mount the Raspberry board safely so that it doesn't tumble around in the housing.
As our housing had a very large glass window at the front, we have closed it with a black paper with a hole in it. This has the advantage that the "tech" of the camera is not visible anymore. If you like the camera recording led to be visible, don't cover it. Whenever the camera is detecting any motion or is recording, the led light will glow in a very bright red.
You can also turn off the camera red LED by adding this line to /boot/config.txt:

disable_camera_led=1



Step 7: Installing the motion detection software

A very good (and free open-source) motion detection/surveillance software with many configuration options is motion.
We now need to install it using the command line (log in to your raspberry as user "pi"):
sudo apt-get install motion 
Some packages will be installed in the installation process; just type "y" to proceed with the installation.
As the current version of motion does not (yet) support the Raspberry camera module, we need to download and install a special build with support for this camera module.
cd /tmp 
sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev
wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz  
And now you need to unpack the downloaded file to the /tmp directory:
tar zxvf motion-mmal.tar.gz  
After this unzipping, you now need to update your installed motion with the downloaded build:
sudo mv motion /usr/bin/motion
sudo mv motion-mmalcam.conf /etc/motion.conf  
You also need to enable the motion daemon so that motion will always run:
sudo nano /etc/default/motion
and change the line to:
start_motion_daemon=yes
We're pretty sure that the official build of motion will shortly also support the Raspberry camera module as well.
A very important command to edit the motion configuration file is
sudo nano /etc/motion.conf  
Note: in the standard motion installation, the motion.conf is in /etc/motion/, but in the special motion-mmal build from dropbox-url (see above) it's in /etc/. If you follow this tutorial with all steps, this is no problem at all.
Be sure to have the file permissions correct: when you install motion via ssh while being logged in as user "pi", you need to make sure to give the user "motion" the permissions to run motion as service after reboot:
sudo chmod 664 /etc/motion.conf
sudo chmod 755 /usr/bin/motion
sudo touch /tmp/motion.log
sudo chmod 775 /tmp/motion.log  
We've made some changes to the motion.conf file to fit our needs. Our current motion.conf file can be downloaded here. Just download, unzip and copy the containing motion.conf to /etc/motion.conf if you would like to use the exact config options we describe below.
Some of the main changes are:
Make sure that motion is always running as a daemon in the background:
daemon on 

We want to store the logfile in /tmp instead (otherwise autostart user won't be able to acces it in /home/pi/ folder):

logfile /tmp/motion.log
As we want to use a high quality surveillance video, we've set the resolution to 1280x720:
width 1280
height 720 
We don't need real-time video, 2 pictures per second are totally ok for our needs:
framerate 2 
This is a very handy feature of the motion software: record some (2 in our configuration) frames before and after the motion in the image was detected:
pre_capture 2
post_capture 2 
We don't want endless movies. Instead, we want to have max. 10 minutes slices of the motion videos. This config option was renamed from max_movie_time to max_mpeg_time in motion. If you use the motion-mmal build, this one will work. If you get an error 'Unknown config option "max_mpeg_time"' either change this one to max_movie_time or make sure to really use the motion-mmal build as shown above.
max_mpeg_time 600 
As some media players like VLC are unable to play the recorded movies, we've changed the codec to msmpeg4. Then, the movies play correctly in all players:
ffmpeg_video_codec msmpeg4  
Enable access to the live stream from anywhere. Otherwise only localhost (= the Raspberry device) would be allowed to access the live stream:
stream_localhost off 
If you want to protect the live stream with a username and password, you should enable this:
stream_auth_method 2  
stream_authentication SOMEUSERNAME:SOMEPASSWORD 
All configuration parameters are explained in detail in the motion config documentation.
After your changes to the motion.conf, reboot the Raspberry:
sudo reboot  
After the reboot, the red light of the camera module should be turned on, which shows that motion currently is using the camera to detect any movement.

Step 8: Save videos on Windows shared folder

As the SD card of the Raspberry Pi is a pretty limited resource, we've decided to let the Raspberry cam store the videos on one of our Windows Servers. This is pretty easy:
First share a folder from some Windows machine. Just follow some guides on the internet if you've never shared a folder from a Windows machine before.
Then open the fstab configuration on your Raspberry from a PuTTY console or directly from the device:
sudo nano /etc/fstab  
Now add an extra line with the configuration of your Windows network shared folder:
//YOURSERVERNAME/YOURSHAREDFOLDERNAME /mnt/camshare cifs username=YOURSHAREDFOLDERUSERNAME,password=YOURSHAREDFOLDERPASSWORD,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0 
Be sure that the user has the correct permissions to save files to that shared folder.
After a reboot, the Raspberry should have an extra folder /mnt/camshare mounted to the Windows shared folder. You should now set in your motion.conf:
target_dir /mnt/camshare 
so that motion saves all movies to the shared folder on the Windows machine.


Step 9: Fix motion autostart

Picture of Fix motion autostart
We had some trouble that motion was not automatically started on a reboot of the Raspberry. We've found out that this was because the mounted folder of the Windows machine was not yet ready when motion tried to access it.
A very quick fix solved our problem:
Just edit the motion file with
sudo nano /etc/init.d/motion 
and add the line
sleep 30 
to the start-sequence.
Our changed /etc/init.d/motion script can be downloaded from here.

Step 10: Mounting the camera

Picture of Mounting the camera
After all these steps, you can finally mount the surveillance camera to the destination point.
Some helpful hints:
  • Be sure to place the power supply in a dry and safe place
  • Keep an eye on the WiFi signal: if you mount the camera out of range of the WiFi, it won't be able to send any live video nor save any motion videos

Step 11: Accessing the live stream

Now you can access the live stream from the camera from any browser via the url http://IPADDRESSOFRASPBERRY:8080
Where 8080 is the port that we've configured for our stream in the motion.conf file. See your own configuration setting "stream_port" in motion.conf for the port.
We've found out that Google Chrome 30 (not even on iOS) wasn't able to play this stream directly due to a bug in the underlying Chromium project.
A workaround for this is to create a simple html file that contains one large image with the stream-url of the camera. See the file cam.html from raspberry_surveillance_cam_scavix.zip. This way, Chrome can show the live stream as well. Let's hope that Chrome will fix this issue in their browser.
But other browsers like FireFox, Safari and even VLC media player was able to show the live stream of the camera.
We were not able to make the live stream work in Internet Explorer as it doesn't support Motion JPEG. Kenneth Lavrsen (the maker of motion) has described workaround for live stream in Internet Explorer here.

Step 12: Access live stream from anywhere

Picture of Access live stream from anywhere
live_stream_mobile.jpg

To make the live stream accessible from anywhere, you will need to enable some kind of dynamic domain services to your local network. This will enable you to always be able to connect to your local IP address from the outside even if your local IP address changes (over here in Germany, every private DSL ip address changes every 24 hours).
Such a (free) service enables you to access your Raspberry from anywhere even if your ip address changes. A very good service we're using for some years now is dyn.com. They have some free services and are integrated in many routers.
Once you have set up the dynamic ip url, you can access the camera stream from anywhere in your browser (i.e. http://YOURDYNAMICDOMAIN:8080).
And this also works from the browser on your mobile device.

Step 13: Next steps

There are a thousand things you can do with such a surveillance cam basic setup now. How about sending Growl notifications when some motion was detected? This guide explains how to add this functionality easily.

Or you could easily add a temperature-sensor to the cam. It's only a few bucks and can be integrated very easily.
We're currently working on integrating the live stream into MediaPortal server so that we can switch to a TV channel to see the live stream from the cam in our office.

If you want extra security, you could also add a battery pack to the camera. Be sure to buy one that is able to charge simultaneously while powering the Raspberry. This would enable you to detect if some bad guy cuts the power strips of your camera and send some alert messages to you (i.e. SMS or email) including the video of the disturber.

What are you going to add? Let us know!

1-40 of 260Next »
AnanthS110 hours ago

Sorry, if this is a silly question, but there wouldn't happen to be any changes if I'm using a Rasberry Pi B+ instead of a Rasberry Pi B would there?

imaczech.2 days ago

I have a question here. I thought that If shared with PC, the video content would also mirror to the SD card as well, right? That would defeat the purpose of using PC as server.

Or perhaps nothing was stored in pi and only was stored in PC? How does it work? Anyone knows?

Thanks

scavix (author)  imaczech.2 days ago

The videos are only stored in one place, not on sd card and additionally on PC shared folder.

Prenze9 days ago

I could really use a quick answer as I'm considering buying this for my parents for christmas. I know for a fact that they don't have any storage options as they won't leave any PC running. However, I figured they most likely won't need to cover any more than 12/24 hours of film. Can anybody here tell me if it's possible to script the rpi to remove the recorded files and start over once a day or so?

OK, after another half a dozen hours of troubleshooting last night, I think I have it mostly working. A couple of important things learned:

1. Shared folder access. No matter how hard I tried, I couldn't get the linux program to port the files over to the shared folder. But then I changed the server name to the IP address of the server machine. (e.g., 192.168.15.XXX). I didn't have the shared folder on the Windows machine password protected but it kept asking me for a password anyway, so I included the username and left the password field blank. This didn't work either. Then, I changed the name of the user account on the Windows machine to a single word (it previously contained two words, separated by a space) This did the trick. Files recorded by Motion are being stored on the shared folder on the Windows machine.

2. Motion. Very important to ensure that your motion.conf file is stored in the correct directory. It should be in /etc/, not in /etc/motion/

3. I was only able to get the daemon to remain "on" by configuring it via the IP config port the motion.conf file does not seem to keep it running when you log out of the terminal -- e.g., start Motion from the terminal after logging into the Pi from the terminal then enter "motion -n" (without parens) then go to your browser (NOT IE, NOT Chrome) I used Firefox, the others don't seem to work. Enter the ip address of the machine followed by a colon ":" and the the admin port number -- e.g., 192.168, XXX.XXX:8081 and you will see some options if your connection is working. chose "list" then keep going until you see daemon with an option box that lets you select On and Off. Select On and save it.

I'll post more later. My system seems to be working as it should now, recording in initial image when it detects motion, the recording 1 frame every 2 seconds and making an .avi file and storing both in my shared Windows folder.

ChristianK22 months ago

What is going wrong, if there is no folder "/mnt/camshare" created upon reboot? My shared folder is reachable from other windows machines in the same network. And no errors are showed.

Thx for any help!

Have you fix this problem? I've got the same problem with you and don't know how to fix it.

I've changed the whole "automount" architecture - I used autofs with a special "map" - So it will work with different servers and shares (without setting up every share in fstab. Some procedure is described here:

http://wiki.centos.org/TipsAndTricks/WindowsShares...

One problem I had with a win7 pc was the "sec"-option - Just removed it, and everything worked fine.

Hope I could help,

greetings :)

I'll have a try. Thank you so much for your help.

sasfater3 months ago

If you have permission problems (myfopen: Error opening file etc) use motion process uid to mount filesystem.

//YOURSERVERNAME/YOURSHAREDFOLDERNAME /mnt/camshare cifs username=user,password=pwd,uid=motion,iocharset=utf8, file_mode=0777,dir_mode=0777 0 0

Don't work either, what should I do?

This project is a great application. Thanks for putting it together. Like a lot of other folks in he comments, I'm struggling with getting this app to work as expected. Spent at least 30 or more hours on this and still not there yet.

Here's the current status. Any help greatly appreciated.

ISSUE 1: Have managed to get the cam to take videos and to store them on /mnt/camshare. No luck at all getting the images and videos to port over to my Windows 7 shared folder. And, because the permissions for this directory are assigned to /root, I can't even delete the files from the SD card on the Pi as they pile up. Have tried with both the terminal command and with WinSCP. Permission denied in all cases.

I've executed all the commands in the instructions above meticulously (several times, in fact) and there are still issues.

QUESTION 1: How can I change the permissions to permit user Pi to modify, edit, delete files in the Pi?

ISSUE 2: Files do not transfer from mnt/camshare to my shared network drive folder. I've configured the fstab file with the network share as directed but no files are being transferred there, even when Motion is running.

QUESTIONS 2: Can anyone provide any more detailed instruction on how to set up fstab to ensure that the files are being stored on the shared network folder rather than on the Pi camshare folder?

ISSUE 3: Motion not running via daemon. Motion only runs when started from the command line with "motion -n". Even with the motion.conf file clearly configured "daemon = on", it never runs unless I manually start it.

And once it runs, it captures images continuously at a rate of 2X/sec until I stop it, but never on motion detection. Perhaps the sensitivity is too high and it's detecting movement from trees in the background?

QUESTION 3: How can I get the daemon to run Motion when the Pi boots?

I love this app and appreciate the time that the author has taken to build it but I'm just about to run out of time and patience trying to get the bugs sorted out.

Any help greatly appreciated.

Best wishes and thanks for any thoughts, ideas, suggestions and thanks again for developing this app.

I need help!

I successfully installed motion

I am able to stream on internal and external ip address after port forwarding

I cannot get it to email me on motion detection

I was able to have detected images to be viewable in the target directory

Camera shuts off when it detects motion when set up for email

Does anyone have instructions on how to have it email you the pics to gmail?

What are the specific instructions when configuring postfix as Internet site or Internet site with smarhost? For instance, what do I put on hostname or relay host? Is it my email?

The latest version of Motion works with the Pi camera but you need to install the V4L2 (video4linux) driver to enable the cam to show up as /dev/video0.

http://www.raspberrypi.org/forums/viewtopic.php?f=...

The easiest way to make the livestream available on all devices is to enable Camboloza as described in the official Wiki.

http://www.lavrsen.dk/foswiki/bin/view/Motion/Webc...

Unfortunately I cannot figure out how to set up the live stream with authentication. If anyone can shed some light on this, it would be greatly appreciated!

OK, so are you saying there is no "need to download and install a special build with support for this camera module" in STEP 7. Is that right -- Great I had so much lovely practice rebooting, editing, reading about fstab and backing up images. - What fun!!

Now, if you could be so kind, can you tell me where can I get some help line by line instructions on downloading and installing v4l2 and Camboloza for this application?

If not perhaps instructables.com should remove this entire project as obsolete.

AaronD5 AaronD526 days ago

Now getting files written to windows by adding a domain and default parameters to fstab.

AaronD526 days ago

---------- ??? Can anyone tell me why mnt/camshare from the command line works:

sudo mount -t cifs -o username=uuuu,password=pppp //192.168.1.123/temp /mnt/camshare

-----------??? but /etc/fstab does not. The camera lights come on but no files in /mnt/camshare???:

//192.168.1.123/temp /mnt/camshare cifs username=uuuu,password=pppp,domain=WORKGROUP ocharset=utf8,file_mode=0777,dir_mode=0777,dir_mode=0777 0 0

-----------??? In /etc/motion.conf target_dir /mnt/camshare

Thanks, sorry I'm pretty new at this may be a mater of experience thing.

Interesting project. I love to try this

power0001 month ago

Hello , i am trying to sent recorder files to my computer but i cannot.i open

sudo nano /etc/fstab

and i add

//Mainfraime/Documents/Raspberry_Cam /mnt/camshare cifs username=Mainframe/Documents/Raspberry_Cam,password=0000,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

Is those right???

and

target_dir /mnt/camshare

What is target_dir??

Is it "Documents/Raspberry_Cam" folder?

thank you

Excellent tutorial, thanks!

I got annoyed a bit waiting 30 seconds every time I started the service, so I changed the startup script to this:

if grep -qs '/mnt/Kamera' /proc/mounts; then

log_daemon_msg "$DESC" ": Mount is ready"

else

log_daemon_msg "$DESC" ": Sleeping 30, mount is not ready"

sleep 30

fi

Now it only waits when the mount is not ready (usually at startup). When I stop/start later for testing purposes, it doesn't wait.

I also found a casing that does not look like a security camera: https://www.modmypi.com/nwazet-pi-camera-box-bundle-plus

The kit even contains a fisheye lens.

ibenkos1 month ago
So smart idea! Thanks for shearing :)
Robbo_roberto2 months ago

Same here. I downloaded the motion file from the link and then copied it into the init.d directory. Still can't get motion to run, nor able to create a path to the server on my desktop machine where I'd like to store the files.

I find my problem... the fstab !

If i don't link my camshare directory to my network, motion is working OK.
I just need to find the right right to use in the fstab.

hi, did you ever get this to work as i have the same problem, something in fstab stopping linking camshare directory to my network.... thanks..

Jason, just an FYI, and I'm sure it's been mentioned - Class "C" subnet addresses (those beginning in 192.168.*.*) are not routable from outside your domain.

hi, yep understood as its a lan and not wan address. but it wont even work on lan... :(

JSWheeler1 month ago

Alright guys I could use some help as well. I can get everything to work. my fstab settings are correct. I can edit text files on the pi and watch them change on the drive on my computer. But I get this error in the log files when I try to run motion

ffmpeg_open: url_fopen - error opening file /security/captures/01-20141105044636.avi ... check access rights to target directory

event_ffmpeg_newfile: ffopen_open error creating (new) file [/security/captures/01-20141105044636.avi]:

I've done chmod chgrp chown and everything I could find online. It has to be in the permissions somewhere.

Hello,

As you can see in the below snippet of motion.log, it doesn't work; trying to restart all the time. Could you please help me?

[-1243126112] [NTC] [ALL] [Nov 04 08:29:14] motion_startup: Using log type (ALL) log level (NTC)

[-1243126112] [NTC] [ENC] [Nov 04 08:29:14] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785

[0] [NTC] [ALL] [Nov 04 08:29:14] main: Thread 1 is from /etc/motion.conf

[0] [NTC] [ALL] [Nov 04 08:29:14] main: Thread 1 is device: /dev/video0 input -1

[0] [NTC] [ALL] [Nov 04 08:29:14] main: Stream port 8080

[0] [NTC] [ALL] [Nov 04 08:29:14] main: Waiting for threads to finish, pid: 2140

[0] [NTC] [STR] [Nov 04 08:29:14] httpd_run: motion-httpd testing : IPV4 addr: 0.0.0.0 port: 8081

[0] [NTC] [STR] [Nov 04 08:29:14] httpd_run: motion-httpd Bound : IPV4 addr: 0.0.0.0 port: 8081

[1] [NTC] [ALL] [Nov 04 08:29:14] motion_init: Thread 1 started , motion detection Enabled

[1] [ALR] [VID] [Nov 04 08:29:14] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 2592 x 1944 at 2 fps

[1] [ALR] [VID] [Nov 04 08:29:14] mmalcam_start: MMAL Camera using still capture

[0] [NTC] [STR] [Nov 04 08:29:14] httpd_run: motion-httpd/mmaltest running, accepting connections

[0] [NTC] [STR] [Nov 04 08:29:14] httpd_run: motion-httpd: waiting for data on 0.0.0.0 port TCP 8081

[1] [NTC] [VID] [Nov 04 08:29:14] MMAL camera component created

[1] [NTC] [ALL] [Nov 04 08:29:17] image_ring_resize: Resizing pre_capture buffer to 1 items

[1] [NTC] [STR] [Nov 04 08:29:17] http_bindsock: motion-stream testing : IPV4 addr: 0.0.0.0 port: 8080

[1] [NTC] [STR] [Nov 04 08:29:17] http_bindsock: motion-stream Bound : IPV4 addr: 0.0.0.0 port: 8080

[1] [NTC] [ALL] [Nov 04 08:29:17] motion_init: Started motion-stream server in port 8080 auth Disabled

[1] [NTC] [ALL] [Nov 04 08:29:17] image_ring_resize: Resizing pre_capture buffer to 4 items

[0] [ERR] [ALL] [Nov 04 08:29:47] main: Thread 1 - Watchdog timeout, trying to do a graceful restart

[0] [NTC] [STR] [Nov 04 08:29:47] httpd_run: motion-httpd - Finishing

[0] [NTC] [STR] [Nov 04 08:29:47] httpd_run: motion-httpd Closing

[0] [NTC] [STR] [Nov 04 08:29:47] motion_web_control: motion-httpd thread exit

[0] [ERR] [ALL] [Nov 04 08:30:47] main: Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!

[0] [NTC] [STR] [Nov 04 08:30:47] stream_stop: Closing motion-stream listen socket & active motion-stream sockets

[0] [NTC] [STR] [Nov 04 08:30:47] stream_stop: Closed motion-stream listen socket & active motion-stream sockets

[0] [ALR] [VID] [Nov 04 08:30:47] MMAL Camera cleanup

[0] [NTC] [ALL] [Nov 04 08:30:48] main: Motion thread 1 restart

[1] [NTC] [ALL] [Nov 04 08:30:48] motion_init: Thread 1 started , motion detection Enabled

[1] [ALR] [VID] [Nov 04 08:30:48] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 2592 x 1944 at 2 fps

[1] [ALR] [VID] [Nov 04 08:30:48] mmalcam_start: MMAL Camera using still capture

[1] [NTC] [VID] [Nov 04 08:30:48] MMAL camera component created

[1] [NTC] [ALL] [Nov 04 08:30:51] image_ring_resize: Resizing pre_capture buffer to 1 items

[1] [NTC] [STR] [Nov 04 08:30:51] http_bindsock: motion-stream testing : IPV4 addr: 0.0.0.0 port: 8080

[1] [NTC] [STR] [Nov 04 08:30:51] http_bindsock: motion-stream Bound : IPV4 addr: 0.0.0.0 port: 8080

[1] [NTC] [ALL] [Nov 04 08:30:51] motion_init: Started motion-stream server in port 8080 auth Disabled

Thanks in advance.

JasonM82 months ago

having a problem with this one. the camera light comes on for 10 secs at bootup then goes off, and the software does not seem to start the server on port 8080/8081 as both give 'page not available'. i have set permissions using chmod as in the instructions, and have followed the guide to the letter, but still no joy :( ideas?

NathanD1 JasonM82 months ago

Same problem here. Followed the instructions to the "T".

caz1121 NathanD12 months ago
Have you double checked the camera module is defect free? I bought one specifically to follow this tutorial, so assumed camera was fine as brand new. After 5 days and countless installs of Raspian, it turns out the ribbon to the camera module was defective, LED came on, but evidently it did nothing more.. Error after error.. I typed in a TX Terminal window raspivid - t 2000.. Nothing happened. Returned camera for replacement and all is well :)
JasonM8 caz11212 months ago

hi, thanks for the reply. I just checked my camera with raspivid -t 2000 and have a picture. i then tried for a longer time 20000 and still a picture for the full 20 secs, so rules out a faulty camera ....

i have also tried to restart the service using

sudo service motion reload

and get the response

reloading motion configuration:No /usr/bin/motion found running; none killed. failed!

so i guess the server is not starting, but the camera led comes on for 15 secs at bootup still though?

i am really scratching my head on this one, as it would seem others are too...

JasonM8 JasonM81 month ago

finally getting somewhere. i copied the config file in the above link onto my raspberry and changed the working directory to /tmp and it now works on the raspberry, i can see .avi files and .jpeg files, so have no idea why the default one does not work??... but the server is NOT running still! :-( i changed stream port to 9000 and used vlc player on my windows pc, but nothing. double checked my virgin media router is letting port 9000 through. so am now stuck again :-( 10 hours later and still not there yet... *** update - the server will only work on port 8080 and no other! now all i need is to get the fstab to put the avi onto my windows pc and work correctly! challenges challenges! (and many hours!)

JasonM8 JasonM81 month ago

cant get this fstab to upload files to my windows server :-(

can someone post their fstab on here to see where im going wrong?

mine is :

//192.168.0.5/priv/picam /tmp cifs username=xxxx,password=xxxx,uid=motion,iocharset=utf8, file_mode=0777,dir_mode=0777 0 0

Tonx761 month ago

I have a raspberry with Noir camera. I installed motion than davfs2 with box.com account, mounted a directory from box.com and I save the avi files right to this folder which is physically on the server. But, if I don't give full rights to the box folder on the raspberry motion won't save the files there. I always get access error.

With sudo chmod 777 /home/pi/box motion has full access. But after restart this access is gone, and I have to type it again. If it's working I sometimes still get files with 0kb and watchdog error. What should I do that this motion should work fine and without errors?

Toni_Chaz1 month ago

Very nice tutorial. Good job.

NathanD11 month ago
I'm getting your replies via email but not seeing them on here... Did you get it working?
cjwessing2 months ago

Thanks for the excellent write-up! I set mine up with a NoIR camera and LED spotlight and let it outside for a few weeks. Seen alot of birds, squirrels and mice, but last night I got a new visitor!

Coyote Caught with Raspberry Pi and NoIR camera:

TimBobTastic2 months ago

I have made a few changes to my config file and finally come up with a video camera that takes video at better than 1fps... take a look at my website for the instructions... http://timbobtastic.com/raspberry-pi-security-came...

I am using the Pi NoIr camera, which changes the daytime colours a little, but overall gives good results.... All I need to do now is find a camera body large enough to take the B+... having a power adaptor at the side increases the size requirement a little.....

I have found that you do not need to reboot the RasPi after making changes to the motion.conf file... you can simply restart the service by using the following command...

sudo service motion reload

That should save you some time when you are trying out different parameters...

1-40 of 260Next »