Dies ist eine alte Version des Dokuments!


Http Live Streaming (HLS) mit nginx

Stream URL: rtmp://NGINX-SERVER/livestream kkk
Stream Key: frei wählbar z.B.: stream

Installation

apt install build-essential libpcre3 libpcre3-dev libssl-dev zlib1g zlib1g-dev
git clone https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar -xf nginx-1.16.1.tar.gz
cd nginx-1.16.1

nginx am besten in eigenes Verzeichnis kompilierern (über –prefix)

./configure --prefix=/usr/local/nginx-rtmp --with-http_ssl_module --add-module=../nginx-rtmp-module
make
make install

Ordner erstellen in dem der Stream zur Auslieferung gespeichert wird. Konnte auch in einem bestehende documentroot eines anderen Webservers liegen.
Dann entfällt der http Teil der nginx Konfiguration

mkdir -p /stream/hls/

nginx Konfiguration

worker_processes  auto;
events {
	worker_connections  1024;
}

# RTMP configuration
rtmp {
	server {
		listen 1935; # Listen on standard RTMP port
		chunk_size 4000;

		application livestream {
			live on;
			# Turn on HLS
			hls on;
			hls_path /stream/hls/;
			hls_fragment 3;
			hls_playlist_length 120;
			# disable consuming the stream from nginx as rtmp
			deny play all;
		}
	}
}

# HTTP configuration
http {
	sendfile off;
	tcp_nopush on;
	aio on;
	directio 512;
	default_type application/octet-stream;
	
	server {
		listen 80;
		server_name localhost;
		
		root /stream/;
		
		location / {
			#index  index.html index.htm;
			autoindex on;
		}
		
		location /hls/ {
			default_type application/octet-stream;
	
			# 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;
			}
		}
	}
}

OBS Studio

Stream URL: <pre>rtmp://NGINX-SERVER/livestream</pre> kkk
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.

pub/http-live-streaming.1586546418.txt.gz · Zuletzt geändert: (Externe Bearbeitung)