Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| pub:http-live-streaming [2020/04/10 21:20] – Marco Krage | pub:http-live-streaming [2020/04/10 22:21] (aktuell) – Marco Krage | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== | + | ====== |
| - | Stream URL: '' | + | Wir bauen hier einen speziellen nginx, mit einem rtmp Modul, welcher einen rtmp Stream |
| - | Stream | + | Optional stellt er dieses auch direkt als Webserver bereit. Das Verzeichnis könnte aber von einem bestehenden Webservers ausgeliefert werden. |
| ===== Installation ===== | ===== Installation ===== | ||
| apt install build-essential libpcre3 libpcre3-dev libssl-dev zlib1g zlib1g-dev | apt install build-essential libpcre3 libpcre3-dev libssl-dev zlib1g zlib1g-dev | ||
| + | |||
| + | RTMP Modul clonen | ||
| git clone https:// | git clone https:// | ||
| + | | ||
| + | Aktuellen Build von nginx laden und entpacken | ||
| wget http:// | wget http:// | ||
| tar -xf nginx-1.16.1.tar.gz | tar -xf nginx-1.16.1.tar.gz | ||
| cd nginx-1.16.1 | cd nginx-1.16.1 | ||
| - | nginx am besten in eigenes Verzeichnis kompilierern (über '' | + | nginx am besten in eigenes Verzeichnis kompilierern (über '' |
| ./configure --prefix=/ | ./configure --prefix=/ | ||
| make | make | ||
| make install | make install | ||
| - | Ordner erstellen in dem der Stream zur Auslieferung gespeichert wird. Konnte auch in einem bestehende documentroot eines anderen Webservers liegen. | + | Ordner erstellen in dem der Stream zur Auslieferung gespeichert wird. |
| - | Dann entfällt der http Teil der nginx Konfiguration | + | |
| - | mkdir -p /stream/hls/ | + | mkdir -p /var/www/hls/live |
| + | mkdir -p / | ||
| + | mkdir -p / | ||
| ===== nginx Konfiguration ===== | ===== nginx Konfiguration ===== | ||
| < | < | ||
| - | worker_processes | + | #user nginx; |
| + | worker_processes auto; | ||
| events { | events { | ||
| - | worker_connections | + | |
| } | } | ||
| - | # RTMP configuration | + | # RTMP Konfiguration |
| rtmp { | rtmp { | ||
| - | server { | + | |
| - | listen 1935; # Listen | + | listen 1935; |
| - | chunk_size 4000; | + | chunk_size 4096; |
| + | ping 30s; | ||
| + | notify_method get; | ||
| + | allow play all; | ||
| + | | ||
| + | | ||
| + | live on; | ||
| + | hls on; | ||
| + | hls_path / | ||
| + | hls_nested on; # create a new folder for each stream | ||
| + | record_notify on; | ||
| + | record_path / | ||
| + | record all; | ||
| + | record_unique on; | ||
| + | } | ||
| - | application | + | |
| - | live on; | + | |
| - | # Turn on HLS | + | } |
| - | hls on; | + | } |
| - | hls_path | + | |
| - | hls_fragment 3; | + | |
| - | hls_playlist_length 120; | + | |
| - | # disable consuming the stream from nginx as rtmp | + | |
| - | deny play all; | + | |
| - | } | + | |
| - | } | + | |
| } | } | ||
| - | # HTTP configuration | + | # HTTP Konfiguration |
| http { | http { | ||
| - | sendfile off; | + | include |
| - | tcp_nopush on; | + | default_type |
| - | aio on; | + | |
| - | directio 512; | + | |
| - | default_type application/ | + | |
| - | + | | |
| - | server { | + | |
| - | listen 80; | + | |
| - | server_name localhost; | + | |
| - | + | ||
| - | root /stream/; | + | |
| - | + | ||
| - | location / { | + | |
| - | # | + | |
| - | autoindex | + | |
| - | } | + | |
| - | + | ||
| - | location /hls/ { | + | |
| - | default_type application/ | + | |
| - | + | ||
| - | # Disable cache | + | |
| - | add_header ' | + | |
| - | # CORS setup | + | autoindex on; |
| - | add_header ' | + | |
| - | add_header ' | + | |
| - | # allow CORS preflight requests | + | location / { |
| - | if ($request_method = ' | + | root /var/www/html; |
| - | add_header ' | + | index index.html index.htm; |
| - | add_header ' | + | } |
| - | add_header ' | + | # the http end point our web based users connect to see the live stream |
| - | add_header ' | + | |
| - | return 204; | + | |
| - | } | + | application/ |
| - | + | } | |
| - | types { | + | alias /var/ |
| - | application/ | + | |
| - | application/ | + | } |
| - | video/mp2t ts; | + | } |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| } | } | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ===== Web Player ===== | ||
| + | ''/ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <meta charset=utf-8 /> | ||
| + | < | ||
| + | <link href=" | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | <source src=" | ||
| + | </ | ||
| + | |||
| + | <script src=" | ||
| + | <script src=" | ||
| + | |||
| + | < | ||
| + | var player = videojs(' | ||
| + | liveui: true | ||
| + | }); | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Streamen ===== | ||
| + | STREAM-KEY ist ein freiwählbarer Name | ||
| + | |||
| + | Stream Ziel ist: ''< | ||
| + | |||
| + | Die Playlist des Stream dann unter ''< | ||
| + | |||
| + | ==== ffmpeg ==== | ||
| + | |||
| + | ffmpeg -i / | ||
| ===== OBS Studio ===== | ===== OBS Studio ===== | ||
| - | Stream URL: <pre>rtmp://NGINX-SERVER/livestream</pre> kkk | + | Stream-URL: '' |
| - | Stream Key: frei wählbar z.B.: stream | + | Stream-Key: frei wählbar z.B.: stream |
| - | nach dem Stream Key richtet sich auch die playlist und clip Namen welche dann über den Webserver aufrufbar sind. | + | Nach dem Stream Key richtet sich auch die playlist und clip Namen welche dann über den Webserver aufrufbar sind. |
| + | |||
| + | |||
| + | |||
| + | Quellen: | ||
| + | https:// | ||
| + | https:// | ||
| + | https:// | ||