User:Nathanlkoch/Tutorials/Streaming
Streaming
Client
Managing streams can be cumbersome using a web front end. Multiple tabs on various streams. I highly recommend installing the following software combination.
https://github.com/streamlink/streamlink
https://github.com/streamlink/streamlink-twitch-gui
https://github.com/Chatterino/chatterino2
along side
root #
emerge --ask --verbose mpv
It will provide a Twitch like Desktop app that opens streams that can be granularly configured with mpv and a chat dialogue.
Server
Streaming with NGINX and RTMP-module and HLS
NGINX Config
####### RTMP STREAMING SERVER rtmp { server { listen 127.0.0.1:19361; chunk_size 4096; application secret-key { live on; # Turn on HLS hls on; hls_path /var/www/html/domain.com/hls1/; hls_fragment 3; hls_playlist_length 5s; hls_type event; #include pull.conf; record off; allow publish 127.0.0.1; # publishing through rtmps://video.domain.com:1936 allow play all; # for the pull from rtmp://localhost:19351/live } } server { listen 127.0.0.1:19351; chunk_size 4096; application live { live on; record off; # Turn on HLS hls on; hls_path /var/www/html/domain.com/hls/; hls_fragment 3; hls_playlist_length 5s; allow publish all; # no need to publish on /live -- IMPORTANT!!! allow play all; # playing through rtmps://video.domain.com:1935/live pull rtmp://127.0.0.1:19361/secret-key; } } } stream { upstream publish { server 127.0.0.1:19361; } server } server { listen 1936 ssl; # additional port for publishing proxy_pass publish; proxy_protocol on; ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # allow 10.0.0.1; # allow publish from this IP # allow all; allow 10.0.0.0/16; # -- also supports CIDR notation! # deny all; # deny publish from the rest } upstream live { server 127.0.0.1:19351; } server { listen 1935 ssl; #add ssl standard RTMP(S) port proxy_pass live; ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; allow [0.0.0.0 SECRETIP]; deny all; # this is public (this is also the default) } }
<html><head>
<link href="https://unpkg.com/video.js@7/dist/video-js.min.css" rel="stylesheet"> <link href="https://unpkg.com/@videojs/themes@1/dist/city/index.css" rel="stylesheet"> <title>Gentoo</title> <script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script> <script src="https://unpkg.com/video.js/dist/video.js"></script> <script src="https://vjs.zencdn.net/7.10.2/video.min.js"></script> <link href="https://domain.com/images/bash.png" rel="shortcut icon" type="image/x-icon"> <link href="domain.comimages/webclip.png" rel="apple-touch-icon"></head> <style> </style> <body> <body style="background-color:black;">
<video-js id="my_video_1" class="video-js vjs-theme-city vjs-big-play-centered" controls preload="auto" poster="rock.png" data-setup='{"fluid": true}'>
<source src="https://domain.com/hls/stream.m3u8" type="application/x-mpegURL" width="100%" height="100%"></video-js>
<script>
var player = videojs('my_video_1', { html5: { hls: { overrideNative: true } } });</script> </body>
</html>
Then set OBS to stream to rtmps://domain.com:1935/live with your nginx locked to your local ip.