Raspberry Pi Webcam Server

Raspberry Pi Webcam Server - Raspberry Pi Logo

Raspberry Pi Webcam Server Project

 

The Raspberry Pi is a small, cheap mini-computer that runs Linux.  It’s great for tinkering with, and there are many projects online to try.  In this project, I have used Linux ‘motion’ software to setup the device as a Raspberry Pi Webcam Server.

Raspberry Pi Webcam Server - Raspberry Pi

 

Project Definition

The Raspberry Pi Webcam Server will need to monitor and detect movement and will initially be set to record .AVI video files to its 16GB SD Card.  This folder will be open to the network for easy viewing, transferring & deleting of the recorded video files.

Logitech_c615_general_view_4_1In a future revision, the Raspberry Pi Webcam Server will be modified to save directly to either an attached USB hard drive or another networked PC share folder.

The video footage will also be streamed live to my local network and available through the browser on any device.

 

Ingredients

To complete this project I used:

  1. A Raspberry Pi
  2. A SanDisk Ultra 16 GB Class 10 SD Card
  3. A Logitech C615 HD webcam
  4. An externally powered 4 port USB hub
  5. A Logitech MK320 Wireless keyboard & mouse

 

Raspberry Pi Webcam Server Project - SD Card

Booting the Raspberry Pi Webcam Server

I chose to prepare the SD card using a Windows PC.  This involved downloading an SD card image from the Raspberry Pi website for free.

To place the image on to the SD card, I used Win32DiskImager for Windows.

Once completed, I inserted the SD Card into the Raspberry Pi and connected the externally-powered USB hub, Keyboard adapter and LAN cable, then I turned on the Raspberry Pi.

 

Setting up the Raspberry Pi Webcam Server

The standard Login and password for the system is username: pi and the password: raspberry

After logging into the Raspberry Pi, the first step was to configure the Raspberry Pi using the Raspi-Config tool.  I expanded the Root FileSystem, set the correct Time Zone and Locale, Enabled SSH, and set the device to Boot to Desktop option.

Tip: The Raspberry Pi can be reconfigured by running the following command from a terminal window:

sudo raspi-config

I also experimented with overclocking the Raspberry Pi and settled on the medium overclocking choice of 900MHz.

 

Now that the Raspberry Pi boots to the desktop, the next step was to ensure the Raspberry Pi operating system is up to date, using:

sudo apt-get update
sudo apt-get upgrade

I then downloaded and installed motion and ffmpeg

sudo apt-get install motion ffmpeg

and installed samba

sudo apt-get install samba samba-common-bin

 

I created a folder on the Raspberry Pi SD Card where motion will save the .AVI videos to.

sudo mkdir /home/pi/motion

sudo chmod 777 /home/pi/motion

I then edited the Samba configuration file to add the motion folder as a Network Share.

sudo nano /etc/samba/smb.conf

After entering the correct network details near the top of the Samba configuration file:

workgroup = MyNetwork

wins support = YES

I then added the following text to the bottom of the Samba configuration file.

[motion]

 comment=RaspberryPi Motion Share

 path=/home/pi/motion

 browseable = yes

 writeable = yes

 guest ok = yes

 

A quick check from another PC on the network confirms the folder is now visible.

Raspberry Pi Webcam Server - Network Share

 

Configuring the Raspberry Webcam Server

Now the Raspberry Pi is ready for me to setup the Motion configuration file:

sudo nano /etc/motion/motion.conf

I set the following items

daemon on

framerate 2

output_normal off

ffmpeg_cap_new on

ffmpeg_video_codec mpeg4

target_dir /home/pi/motion

webcam_port 8081

webcam_quality 90 

webcam_localhost off

control_port 8080

control_localhost off

Here’s a copy of my completed motion.conf

The full list of Motion Configuration Options are listed here:

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

 

Next, I enabled the motion daemon by editing this configuration file:

sudo nano /etc/default/motion

and I changed start_motion_daemon=NO  to

start_motion_daemon=yes

 

Now start the Motion server service:

sudo service motion start

 

To restart the motion software following changes:

sudo /etc/init.d/motion restart

 

Rather than using a WiFi adapter, I have chosen to use an existing Netcomm NP-204 Broadband Over Powerline adapter, which will provide power and LAN cable internet connection to the Raspberry Pi.

 

Netcomm

 

I had already set my Network Router to provide the Raspberry Pi with a static IP address of 192.168.1.20 for previous projects.  The picture below shows that Address Reservation in the Router Configuration webpage.

 

Raspberry Pi Webcam Server - Router Addresses

 

Now any network connected device, including PCs, Tablets and Smart Phones can now browse to 192.168.1.20:8081 to view the live stream of images from the Webcam.

To remotely configure the motion server, I browse to 192.168.1.20:8081.  The image below is a screenshot taken on a Samsung Galaxy running Firefox for Android.

 

Raspberry Pi Webcam Server - Android Feed

The Raspberry Pi Webcam Server project is now complete.

Raspberry Pi Webcam Server - Setup