How to set up a USB camera with remote access on a Raspberry Pi

Update your repository

cd ~
sudo apt-get update

Download mjpg-streamer

sudo wget

Extract the download

sudo tar xvzf mjpg-streamer.tar.gz

Remove the download file

sudo rm mjpg-streamer.tar.gz

Install libjpeg8

sudo apt-get install libjpeg8-dev

Install imagemagick

sudo apt-get install imagemagick

Move to the main mjpg-streamer directory

cd mjpg-streamer/mjpg-streamer

Run make

sudo make -j4

Get the network address of your Raspberry Pi

sudo ifconfig

Note the address in the inet field


Run mjpg-streamer with a resolution of 320 x 240 at 15 frames per second using port 11111

./mjpg_streamer -i "./ -r 320x240 -f 15" -o "./ -w ./www -p 11111"

Using a web browser navigate to the IP address of your Raspberry Pi using port 11111

View the camera from the mjpg-streamer page

click stream