Raspberry Pi Livestream Security Camera
Needs
- Raspberry Pi with free USB port
- Raspberry Pi camera or USB Webcam
Set up
Get Motion:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install motion -y
Connect and detect camera:
lsusb
All video devices should be displayed with:
ls /dev/video*
Do modprobe
so the camera is automatically displayed:
sudo modprobe bcm2835-v4l2
If you’ve only connected one camera, you can specify it with /dev/video0
.
See camera details with:
v4l2-ctl -V
Create a folder for storing files:
mkdir /home/picam/Motion
sudo chgrp motion /home/picam/Motion
chmod g+rwx /home/picam/Motion
Update the motion configuration file:
sudo vim /etc/motion/motion.conf
# Start in daemon (background) mode and release terminal (default: off)
daemon on
...
# Restrict stream connections to localhost only (default: on)
stream_localhost off
...
# Target base directory for the media files you created
# Use absolute path. (Default: current working directory)
target_dir /home/picam/Motion
...
# Image width (pixels). Valid range: Camera dependent, default: 352
width 640
# Image height (pixels). Valid range: Camera dependent, default: 288
height 480
# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
framerate 10
Activate the motion daemon:
sudo vim /etc/default/motion
start_motion_daemon=yes
sudo service motion start
View the stream at http://raspberrypi:8081/
.