LearnRaspi

Raspberry Pi Webcam Stream Server Tutorial (Live Streaming)

Raspberry Pi Live Stream

Raspberry Pi Live Stream

One of the more popular Raspberry Pi projects is turning your board into a webcam server capable of hosting a live stream. Most people would utilize this as a CCTV system (I plan to) however others will have unique uses. If you have some weird yet wonderful idea, be sure to let me know about it! I think this is accomplishable for about £40/£50, however I used a few bits and pieces that I had lying around and was able to put this together for practically nothing. I used a Logitech Quickcam webcam for this project.

What You’ll Need:

  • A Raspberry Pi (obviously)
  • An SD Card (about 8GB)
  • A webcam
  • An Ethernet Cable or a Wi-Fi Adapter (Wireless Adapter) and Internet Access
  • A powered USB hub
  • A keyboard
  • A mouse (if you chose a WiFi Adapter)
  • Okay, so first we’re going to need to get a fresh install of Debian “Wheezy” onto an SD Card – this is obtainable from the Raspberry Pi website for free. You can put this onto an SD Card using Win32DiskImager for Windows or there’s an alternative app for Mac users that can do this for you.

    Once you’ve done that, insert the SD Card into your Raspberry Pi. Connect either an Ethernet Cable or your Wireless Adapter to your board and the Keyboard. Oh, and don’t forget your externally-powered USB hub.

    Turn on your Raspberry Pi, set the time zone according to where you live from the Raspi-Config menu and then hit Finish.

    Log in if prompted.
    Username: pi
    Password: raspberry

    Before you do anything, you should update your password from the default to prevent intruders. To do this, you should type sudo passwd into the command line. Type a new UNIX password, and you’re ready to go!

    – IGNORE BELOW IF USING AN ETHERNET CABLE –
    If you want to set up your wireless adapter and connect to WiFi in the desktop environment, you’ll need to type in the following to the terminal:

    startx

    You can then set up your wireless connection here. Once finished, click the menu in the bottom left and then ‘Log out’ to return to the command line.
    – IGNORE ABOVE IF USING AN ETHERNET CABLE –

    Now you need to upgrade your system. At the command line, type:

    sudo apt-get update
    sudo apt-get upgrade

    And wait for that to finish. Now we need to install Motion – this is the streaming software that makes everything work with a build in web server. For that, please enter:

    sudo apt-get install motion

    And wait. After installation, please plug in your web cam via the powered USB port. Without the external power boost, your Pi may not be capable of powering the webcam on its own.
    You need to edit the Motion configuration file to make it all work, so enter the following code in the terminal:

    sudo nano /etc/motion/motion.conf

    Your configuration file will appear, and you can change a few settings here if you like. Most importantly though, we need to change the following:

    daemon OFF (to ON – this can be changed near the top of the file)
    webcam_localhost ON (to OFF – this can be changed near the bottom of the file)
    control_localhost ON (to OFF – located just below the above setting)

    Do Ctrl + X to save, type ‘y’ to save save modified buffer, and press enter to confirm the file name.

    Now you need to enable the Daemon to start by typing:

    sudo nano /etc/default/motion

    …and changing start_motion_daemon=NO to start_motion_daemon=yes

    Now we need to start the Motion server:

    sudo service motion start

    Wait for about 60 seconds and then navigate to your Raspberry Pi’s internal IP address (visible on startup of Pi) in your web browser. The latest versions of Firefox work best.

    It should look something like this: 192.168.X.X:8081

    Make sure you include port 8081 at the end, as this is where your webcam images will appear. You can configure your setup in a web-based interface from now on by connecting to port 8080 instead of port 8081.

    Port 8081 – video
    Port 8080 – web configuration interface

    Note: this is only visible on your own WiFi network. If you attempt to view it on a different Internet Connection, it will not work. You can enable Port Forwarding in your router’s GUI to enable global viewing.

    Congratulations! You’ve just made your own Raspberry Pi Webcam Server!

    Troubleshooting Guide

    Does your stream give a grey screen with an error relating to your webcam?
    Type ls /dev/video* into your terminal to find out the name of your video device. The default in the /etc/motion/motion.conf file is normally video0 so if you get a different output then it may require changing. Restart the Motion software to apply changes.

    Categories: Tutorials

    How to install Raspberry Pi Minecraft: Pi Edition (Tutorial) » « How to connect to Raspberry Pi remotely using SSH

    5 Comments

    1. This is good. I would like to see an alternative version of this tutorial using the Raspberry Pi Camera Module.

    2. Is it possible to use 2 or more webcams??
      thanks

    3. Is it possible to use 2 or more webcams with the motion??
      thanks

    4. Can you connect multiple webcams to this?

    Leave a Reply

    Your email address will not be published.

    *

    Copyright © 2017 LearnRaspi

    A little project by joelci.esUp ↑