Multi-Platform Streaming Setup:
I'm going to keep making posts like this, until I either give up on vacation and get a job, or find that one of my active projects warrants way more attention. I know a lot of people here are either watching streams, thinking about streaming, or are already streaming so maybe somebody will find this interesting or helpful.
NGINX is a very popular reverse-proxy (what most people would call a web server). It can be extended with modules, one of which is the
RTMP Module.
Most streamers are sending their stream via RTMP to whatever streaming platform they use. There are lots of services out there you can pay for that will re-stream your stream, do notifications for you stream, etc. A little work and you don't need to pay for any of that shit though.
Here is a basic configuration for NGINX configuration for streaming RTMP. We start with the base config for NGINX itself, and `include` the config for RTMP.
NGINX:
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
ssl on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off;
sendfile on;
keepalive_timeout 70;
include /etc/nginx/conf.d/api.conf;
}
include /etc/nginx/conf.d/rtmp.conf;
NGINX:
rtmp {
server {
listen 1935;
chunk_size 1024;
ping 30s;
notify_method get;
# available on /mystream
application mystream {
allow publish 127.0.0.1;
allow play all;
live on;
push maybe.cozy.tv:1935;
push maybe.rumble.com:1935;
on_play http://localhost:8080/on_play;
on_publish http://localhost:8080/on_publish;
on_done http://localhost:8080/on_done;
}
}
}
If you take a look, you'll see a few configuration options that stand out. The first would be that you can have multiple `
push` statements, and those can be to any endpoint that will accept an RTMP stream. If you want to multi-stream across platforms, your `
push` statements could have cozy, rumble, twitter, etc all in one block, and all you have to do is point your stream to this box. The other interesting options are `
on_play` `
on_publish` and `
on_done` which let you make things happen when your stream changes state. Useful for sending out notifications or kicking off other events. The other nice thing, is that the module can record your streams for you, and will save .ts segments to a folder somewhere which makes clipping incredibly easy. Lastly, and this is more important to some than it is to others, when you use something like this you are placing an intermediary between yourself and the platforms you use. If you're concerned about your info leaking somehow via streaming data, having a hop between you and your destination is a nice safety measure. Lots of potentially cool stuff a person could make around this module! Even your own streaming platform perhaps.