Navigation
Navigation
apt install git gcc make libpcre3 libpcre3-dev openssl libssl-dev zlibc zlib1g zlib1g-dev cd ~ # ab in den Homeordner vom User mkdir restream mkdir restream/nginx-rtmp mkdir restream/hls cd restream
Auf https://nginx.org immer den letzten besorgen. Heute wäre es v1.17.9
wget https://nginx.org/download/nginx-1.17.9.tar.gz tar -xf nginx-1.17.9.tar.gz
Das derzeit aktuelleste rtmp:
git clone https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git
cd nginx-1.17.9/ ./configure --prefix=$HOME/restream/nginx-rtmp/ --with-http_ssl_module --add-module=../nginx-rtmp-module make -j 1 make install cd ~ vim restream/nginx.conf
Wir editieren die Konfiguration von nGinx
Wichtig: für $HOME muss der ganze Pfad angegeben werden!
Zum Anzeigen hier klicken ⇲
Zum Verstecken hier klicken ⇱
worker_processes 1; daemon off; events { worker_connections 1024; } ==== Configuration ==== # RTMP configuration rtmp { server { listen 1935; # Listen on standard RTMP port chunk_size 4096; max_message 32M; application show { live on; # Turn on HLS hls on; hls_path $HOME/restream/hls/; hls_fragment 3; hls_playlist_length 60; # disable consuming the stream from nginx as rtmp deny play all; } } } http { sendfile off; tcp_nopush on; directio 512; default_type application/octet-stream; server { listen 8080; # This URL provides RTMP statistics in XML location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { # XML stylesheet to view RTMP stats. # Copy stat.xsl wherever you want # and put the full directory path here root $HOME/restream/hls/; } location / { # Disable cache add_header 'Cache-Control' 'no-cache'; # CORS setup add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Expose-Headers' 'Content-Length'; # allow CORS preflight requests if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } types { application/dash+xml mpd; application/vnd.apple.mpegurl m3u8; video/mp2t ts; text/html html; } root $HOME/restream/hls/; } } }
Eine recht einfache Seite zum Anschauen des Streams über einen Webbrowser.
vim $HOME/restream/hls/index.html
Zum Anzeigen hier klicken ⇲
Zum Verstecken hier klicken ⇱
<html> <head> <link href="https://vjs.zencdn.net/7.6.6/video-js.css" rel="stylesheet" /> <!-- If you'd like to support IE8 (for Video.js versions prior to v7) --> <script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script> </head> <!-- TODO adjust width, height and poster filename to your needs --> <body> <video id="my-video" class="video-js" controls preload="auto" width="1024" height="576" poster="MY_VIDEO_POSTER.jpg" data-setup="{}" > <source src="hls/stream.m3u8" type="application/x-mpegURL" /> <p class="vjs-no-js"> To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank" >supports HTML5 video</a > </p> </video> <script src="https://vjs.zencdn.net/7.6.6/video.js"></script> </body> </html>
Per Webbrowser:
http://<yourdomain>:8080
oder per VLC:
http://<yourdomain>:8080/hls/stream.m3u8
Nun nur noch OBS den RTMP-Server angeben:
rtmp://<yourdomain>/show
mit irgendeinem Passwort (Bspw. stream)