Skip to content

Plugin that adds a tab to OctoPrint for viewing, starting, and stopping a live stream

Notifications You must be signed in to change notification settings

TheSin-/octoprint-webcamstreamer

 
 

Repository files navigation

OctoPrint-WebcamStreamer

Overview

Plugin that adds a tab to OctoPrint for viewing, starting, and stopping a live stream.

Credits:

Inspired by and based on the work by

Requirements for Streaming

Although this plugin should work with a wide variety of webcam, it has only been tested with a Raspberry Pi cam running on OctoPi and made available via OctoPrint mjpeg-streamer. This plugin relies on a Docker container running FFmpeg to convert the mjpeg-streamer video stream and pipe it to a live streaming service. The YouTube Live and Twitch.Tv streaming services have been tested.

Installation

Using ssh access the OctoPi and install docker:

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
sudo usermod -aG docker pi
sudo systemctl enable docker
sudo reboot now

2-3 minutes after the reboot, ssh back in and test that docker is working:

docker run hello-world

You should see something like this.

If not, try this page for troubleshooting.

Pull the kolisko/rpi-ffmpeg image:

docker pull kolisko/rpi-ffmpeg:latest

Install OctoPrint-WebcamStreamer via one of these 3 methods, also in-depth explained on the official OctoPrint Installing a plugin page.

  1. Open the plugin repository in the Plugin Manager's settings dialog, search for "OctoPrint-WebcamStreamer" and install with the "Install" button.

  2. Open the plugin repository in the Plugin Manager's settings dialog, click on "Get more..." and enter the https://github.com/adilinden-oss/octoprint-webcamstreamer/archive/master.zip URL in the "... from URL" box. Click the Install button to complete the installation.

  3. Access the OctoPi command line and run the ~/oprint/bin/pip install https://github.com/adilinden-oss/octoprint-webcamstreamer/archive/master.zip command.

Setup

Pull up Webcam Streamer in the OctoPi settings panel

  • Enter your streaming providers embed URL for your live stream video into the "Viewer Embed URL" field.

  • Enter your streaming providers ingest or stream server URL into the "Stream Server URL" field.

    • YoutTube: Your complete URL is created by appending your "Stream name/key" to your "Server URL". Both values can be found on your Live dashboard page. With both values in hand, the complete "Stream Server URL" should look like this:

      rtmp:https://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx

    • Twitch: Your complete URL is created by appending your "Primary Stream key" to the rtmp:https://live.twitch.tv/app/ URL. The "Primary Stream key" can be found on your Dashboard Settings page. The complete "Stream Server URL" should look like this:

      rtmp:https://live.twitch.tv/app/live_xxxxxxxxx_xxxxxxxxxx

  • Enter your OctoPi webcam URL into the "OctoPi Webcam URL" field. A fully qualified URL is needed containing either the resolvable hostname or the IP address of the OctoPi. The "OctoPi Webcam URL" typically looks something like this:

      https://192.168.10.79:8080/?action=stream
    

Terse setup information is also availabe via the expandable "Additional Information" section on the "Webcam Streamer" settings page.

Advanced Setup

Advanced option allow for modification of the FFmpeg command line for use with other streaming services or cameras. It also allows for a different Docker container to be specified if desired or needed.

  • "Webcam Frame Rate" default is 10 frames per second which is appropriate for the Raspberry Pi webcam.

  • "Docker Image" default is kolisko/rpi-ffmpeg:latest. This value needs to match the docker image installed in the setup steps.

  • "Docker Container" default is WebStreamer. This value is rather arbitrary but the default makes sense (to me).

  • "FFmpeg Command" allows for customization of the ffmpeg command line. Variable substitution is performed to insert setup values into the ffmpeg command line.

    Default command line for ffmpeg is:

      ffmpeg -re -f mjpeg -framerate 5 -i {webcam_url} {overlay_cmd} -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -acodec aac -ab 128k -vcodec h264 -pix_fmt yuv420p -framerate {frame_rate} -g {gop_size} -strict experimental -filter:v {filter} -f flv {stream_url}
    

    The following variable substitutions are available:

    FFmpeg Cmd Var Settings value
    {stream_url} Stream Server URL
    {webcam_url} OctoPi Webcam URL
    {overlay_cmd} FFMPEG switch To Add A Stream Overlay
    {frame_rate} OctoPi Webcam Frame Rate
    {gop_size} Internal Calculated Value (frame rate * 2)
    {filter} Internal Calculated Value

Todo

  • Reset buttons to restore each advanced value with the click of a button
  • Add way to upload static/base overlay, then copy it to /tmp/overlay.png on start
  • Add template generator for dynamic/static overlay, data to overlay over the static/base and update once or on interval

About

Plugin that adds a tab to OctoPrint for viewing, starting, and stopping a live stream

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 49.9%
  • Jinja 30.2%
  • JavaScript 18.4%
  • CSS 1.3%
  • Less 0.2%