Multistreamer
[discontinued] A webapp for publishing video to multiple streaming services at once.
Install / Use
/learn @jprjr/MultistreamerREADME
Archived
Hi all. I don't enjoy working on this anymore. I'm archiving this repo, you're free to fork it.
Stop emailing me directly.
multistreamer
This is a tool for simulcasting RTMP streams to multiple services:
It allows users to add accounts for their favorite streaming services, and gives an endpoint for them to push video to. Their video stream will be relayed to multiple accounts.
It also allows for updating their stream's metadata (stream title, description, etc) from a single page, instead of logging into multiple services.
It supports integration with Discord via webhooks - it can push your stream's incoming comments/chat messages to a Discord channel, as well as updates when you've started/stopped streaming. There's also a "raw" webhook, if you want to develop your own application that responds to events. See the wiki for details.
Additionally, it provides an IRC interface, where users can read/write comments and messages in a single location. There's also a web interface for viewing and replying to comments, and a chat widget you can embed into OBS (or anything else supporting web-based sources).
Not all services support writing comments/messages from the web or IRC interfaces - please see the wiki for details on which services support which features.
Fun, unintentional side effect: you can use this to push video to your personal Facebook profile, instead of using the phone app. This isn't available via the regular Facebook web interface, as far as I know. :)
Please note: you're responsible for ensuring you're not violating each service's Terms of Service via simulcasting.
Here's some guides on installing/using:
- My User Guide
- A short intro video
- A in-depth tutorial for users
- Installing multistreamer with Docker
- Installing multistreamer without Docker
Table of Contents
- multistreamer
- Table of Contents
- Requirements
- Installation
- Usage
- Reference
- Roadmap
- Versioning
- Licensing
Requirements
- OpenResty 1.13.6.1 or greater, with some extra modules:
- ffmpeg
- lua 5.1
- luarocks
- luajit (included with OpenResty)
- redis
- postgresql
- a POSIX shell (bash, ash, dash, etc)
Note you specifically need OpenResty for this. I no longer support or recommend
compiling a custom Nginx with the Lua module, you'll need the OpenResty
distribution, which includes Lua modules like lua-resty-websocket,
lua-resty-redis, lua-resty-lock, and so on.
Installation
Install with Docker
I have a Docker image available, along with a docker-compose file for quickly getting up and running. Instructions are available here: https://github.com/jprjr/docker-multistreamer
Install OpenResty with setup-openresty
I've written a script for setting up OpenResty and LuaRocks: https://github.com/jprjr/setup-openresty
This is now my preferred way for setting up OpenResty. It automatically installs build pre-requisites for a good number of distros, and installs Lua 5.1.5 in addition to LuaJIT. This allows LuaRocks to build C modules that no longer build against LuaJIT (like cjson).
To install, simply:
git clone https://github.com/jprjr/setup-openresty
cd setup-openresty
sudo ./setup-openresty
--prefix=/opt/openresty-rtmp \
--with-rtmp
Alternative: Install OpenResty with RTMP Manually
You'll want to install Lua 5.1.5 as well, so that LuaRocks can build older
C modules. I have a patch in this repo for building liblua as a dynamic
library, just in case some C module tries to link against liblua for
some reason.
sudo apt-get -y install \
libreadline-dev \
libncurses5-dev \
libpcre3-dev \
libssl-dev \
perl \
make \
build-essential \
unzip \
curl \
git
mkdir openresty-build && cd openresty-build
curl -R -L https://openresty.org/download/openresty-1.13.6.1.tar.gz | tar xz
curl -R -L https://github.com/arut/nginx-rtmp-module/archive/v1.2.1.tar.gz | tar xz
curl -R -L http://luarocks.github.io/luarocks/releases/luarocks-2.4.3.tar.gz | tar xz
curl -R -L https://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz
cd openresty-1.13.6.1
./configure \
--prefix=/opt/openresty-rtmp \
--with-pcre-jit \
--with-ipv6 \
--add-module=../nginx-rtmp-module-1.2.1
make
sudo make install
cd ../lua-5.1.5
patch -p1 < /path/to/lua-5.1.5.patch # in this repo under misc
sed -e 's,/usr/local,/opt/openresty-rtmp,g' -i src/luaconf.h
make CFLAGS="-fPIC -O2 -Wall -DLUA_USE_LINUX" linux
sudo make INSTALL_TOP="/opt/openresty-rtmp/luajit" TO_LIB="liblua.a liblua.so" install
cd ../luarocks-2.4.3
./configure \
--prefix=/opt/openresty-rtmp/luajit \
--with-lua=/opt/openresty-rtmp/luajit
make build
sudo make bootstrap
sudo ln -s /opt/openresty-rtmp/luajit/bin/luarocks /opt/openresty-rtmp/bin/luarocks
Setup database and user in Postgres
Change your user/password/database names to whatever you want.
Editing pg_hba.conf for network access is outside the scope of
this README file.
sudo su - postgres
psql
postgres=# create user multistreamer with password 'multistreamer';
postgres=# create database multistreamer with owner multistreamer;
postgres=# \q
Setup Redis
I'm not going to write up instructions for setting up Redis - this is more of a checklist item.
Setup Sockexec
multistreamer uses the lua-resty-exec module for managing ffmpeg processes,
which requires a running instance of sockexec.
The sockexec repo has instructions for installation - you can either compile from
source, or just download a static binary.
Make sure you change sockexec's default timeout value. The default is pretty
conservative (60 seconds). I'd recommend making it infinite (ie, sockexec -t0 /tmp/exec.sock).
Setup Authentication Server
multistreamer doesn't handle its own authentication - instead, it will
make an authenticated HTTP/HTTPS request to some server and allow/deny user
logins based on that.
You can make a really simple htpasswd-based server with nginx:
worker_processes 1;
error_log stderr notice;
pid logs/nginx.pid;
daemon off;
events {
worker_connections 1024;
}
http {
access_log off;
server {
listen 127.0.0.1:8080;
root /dev/null;
location / {
auth_basic "default";
auth_basic_user_file "/path/to/htpasswd/file";
try_files $uri @auth;
}
location @auth {
return 204;
}
}
}
I have some some projects for quickly setting up authentication servers:
- htpasswd: https://github.com/jprjr/htpasswd-auth-server
- Authenticate users against an htpasswd file
- postgres: https://github.com/jprjr/postgres-auth-server
- Store users in postgres, includes a web interface for adding/managing users
- LDAP: https://github.com/jprjr/ldap-auth-server
- Authenticate users against LDAP
Clone and setup
Clone this repo somewhere, copy the example config file, and edit it as-needed
git clone https://github.com/jprjr/multistreamer.git
cd multistreamer
cp etc/config.yaml.example /etc/multistreamer/config.yaml
# edit /etc/multistreamer/config.yaml
I've tried to comment config.yaml.example and describe what each setting
does as best as I can.
One of the more important items in the config file is the networks section,
right now the supported networks are:
rtmp- just push video to an RTMP URLfacebookmixertwitchyoutube
Each module has more details in the wiki.
Install Multistreamer
For either a global install or self-contained install, you'll need
libyaml and its development headers installed. On Ubuntu, this is libyaml-dev:
apt-get install libyaml-dev
Global install
/opt/openresty/bin/luarocks install multistreamer
If you used the setup-openresty script from above, you'll find
multistreamer at /opt/openresty/bin/multistreamer, else it
depends on your particular setup.
Self-contained install
If you install modules to a folder named lua_modules, the bash script (./bin/multistreamer)
setup nginx/Lua to only use that folder. So,
