Skip to content

Instantly share code, notes, and snippets.

@raspberrypisig
Last active May 11, 2020 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspberrypisig/394b5fbb0ca7b17bed3afc2c0174c8dc to your computer and use it in GitHub Desktop.
Save raspberrypisig/394b5fbb0ca7b17bed3afc2c0174c8dc to your computer and use it in GitHub Desktop.

Live stream your USB webcam and pi camera

Using the package mjpg-streamer

Installation Instructions

curl -sL https://bit.ly/2A43ZHu | bash -

After installation, close your terminal and restart.

Usage

USB Cameras

Look at https://github.com/OctoPrint/OctoPrint/wiki/Webcams-known-to-work for clues for parameters to pass to mjpg-streamer for your camera. If you are lucky, you may not need them.

eg. for my Logitech C920

sudo mjpg_streamer -i "input_uvc.so -r VGA -f 10"  -o output_http.so 

If all is good, you should be able to watch the stream in a browser from

http://IP_ADDRESS_OF_PI:8080/?action=stream

HomeAssistant Usage

camera:
  - platform: mjpeg
    mjpeg_url: http://IP_ADDRESS_OF_PI:8080/?action=stream

Documentation

USB Cameras

Raspberry Pi Camera

#!/usr/bin/env bash
set -xe
sudo apt install -y git cmake libjpeg8-dev libgphoto2-dev
git clone https://github.com/jacksonliam/mjpg-streamer
cd mjpg-streamer/mjpg-streamer-experimental
make
sudo make install
sudo ldconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment