stream-sprout/README.md
2024-07-22 17:19:08 +01:00

7.8 KiB
Raw Blame History

Stream Sprout

Stream Sprout

Restream a video source to multiple destinations such as Twitch, YouTube, and Owncast.

Made with 💝 for Tux (Linux) & Apple (macOS)

 Discord   Mastodon   Twitter   LinkedIn 

Introduction

Stream Sprout 🌱 is a simple, self-contained, and easy-to-use solution for streaming to multiple destinations such as Twitch, YouTube, and Owncast 📡 It uses FFmpeg to receive the video stream from OBS Studio (or anything that can publish a RTMP stream) and then restream it to multiple destinations; providing similar functionality as services like Restream.io and Livepush.io but without the need to pay 💸 for a third-party service or run something like nginx with the RTMP module.

Stream Sprout is designed to be run on the same machine as your OBS Studio instance (but can be run remotely), is configured with a simple YAML file and can be executed by regular users without the need for root privileges.

There is no transcoding or processing of the video stream 🎞️ The stream is received and then restreamed to the destinations you configure without modification. Optionally you can also archive the stream to disk 💾

While the restreaming process is lightweight, your bandwidth requirements will increase with each destination you add. 📈 Ensure you have sufficient bandwidth to support the number of destinations you intend to stream to ⤴️

Stream Sprout is developed on Linux 🐧 and should work on macOS 🍏 or any other platform that supports bash, ffmpeg and yq 👍

Get Started

  • Install Stream Sprout
  • Configure Stream Sprout
  • Configure OBS Studio
  • Start stream-sprout
  • Click the Start Streaming button in OBS Studio

Installation

Debian

yq is available in bullseye-backports, bookworm, trixie and newer.

  • Download the Stream Sprout .deb package from the releases page
  • Install it with apt-get install ./stream-sprout_0.1.0-1_all.deb.

macOS

Install the Stream Sprout requirements using brew:

brew install bash ffmpeg procps yq

Now clone the project:

git clone https://github.com/wimpysworld/stream-sprout.git
cd stream-sprout

Nix & NixOS

FlakeHub

Stable releases of Stream Sprout are published to FlakeHub for Nix users. See the flake on FlakeHub for more details:

Ubuntu 24.04 and newer

yq is available in Ubuntu 24.04 and newer.

  • Download the Stream Sprout .deb package from the releases page
  • Install it with apt-get install ./stream-sprout_0.1.0-1_all.deb.

For Ubuntu versions earlier than 24.04 you can install Stream Sprout from source.

From source

You need to have FFmpeg and yq installed on your system.

git clone https://github.com/wimpysworld/stream-sprout.git
cd stream-sprout

Configure Stream Sprout

Copy the example Stream Sprout configuration and edit it to suit your needs. Stream Sprout will look for a configuration file in the following locations, in this order:

  • Current working directory ./stream-sprout.yaml
  • XDG configuration directory $XDG_CONFIG_HOME/stream-sprout.yaml (Linux) or ~/.config/stream-sprout.yaml (macOS)
  • /etc/stream-sprout.yaml

Server

The server: section is used to configure the RTMP server that Stream Sprout will listen on. url: is the URL that Stream Sprout will listen on; it must be an RTMP URL. If you remotely host Stream Sprout, you should set key: to a secure value to prevent unauthorised access.

If `archive_stream:` is `true` Stream Sprout will archive the stream to disk in the directory specified by `archive_path:`.

### Services

`services:` are arbitrarily named.
Just create an entry for each RTMP destination you want to stream to.
The example configuration includes example entries for Trovo, Twitch, and YouTube.

```yaml
services:
  my-rtmp-destination:
    enabled: true
    rtmp_server: "rtmp://rtmp.example.com/live/"
    key: "my_super_secret_stream_key"

Trovo

Here's an example configuration for Trovo.

services:
  trovo:
    enabled: false
    rtmp_server: "rtmp://livepush.trovo.live/live/"
    key: "<your_stream_key>"

Twitch

Here's an example configuration for Twitch.

services:
  twitch:
    enabled: true
    rtmp_server: "rtmp://live.twitch.tv/app/"
    key: "<your_stream_key>"

Ingest servers

The example configuration uses the primary Twitch ingest server, which is rtmp://live.twitch.tv/app/. If you want to optimise your stream quality, you can use a server closer to your location. A short list of recommended servers based on your location is available from Recommended Ingest Endpoints For You.

You can find a complete list of Twitch ingest servers from https://twitchstatus.com/.

Testing

If you want to test streaming to Twitch without going live, you can use the ?bandwidthtest=true query parameter.

Add ?bandwidthtest=true to the end of your Twitch stream key, this will enable bandwidth testing, which you can monitor at https://inspector.twitch.tv/, and the stream will not go live on your channel.

YouTube

Here's an example configuration for YouTube.

services:
  youtube:
    enabled: true
    rtmp_server: "rtmp://a.rtmp.youtube.com/live2/"
    key: "<your_stream_key>"

Configure OBS Studio

  • Open OBS Studio
  • Go to Settings > Stream
  • Select Custom from the Service dropdown
  • Copy the server url: from your Stream Sprout configuration to the Server field:
    • rtmp://127.0.0.1:1935 (default)
  • Copy the key: (if you specified one) from your Stream Sprout configuration to the Stream Key field

OBS Studio Stream Settings

Limitations

  • Stream Sprout does not support secure RTMP (RTMPS) at this time.
  • Each destination you add will increase your bandwidth requirements.

References

These are some of the references used to create this project: