Table of Contents

nginx-rtmp-module

debian pakete

<code> apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev libbz2-dev libssl-dev tar unzip </code>

compile

<code> ./configure –add-module=../nginx-rtmp-module –with-ipv6 –with-http_stub_status_module </code>

rtmp

/usr/local/nginx/conf/nginx.conf: <code> user www-data;

  1. multiple worker worker_processes 2;
  2. important for multi worker processes!!1! rtmp_auto_push on;

error_log /var/log/nginx/error.log; pid /var/run/nginx.pid;

events { worker_connections 2048; }

http { server { listen [::]:80 default ipv6only=off;

root /srv/nginx/htdocs; index index.html index.htm;

server_name localhost;

  1. html page stuff location / { try_files $uri $uri/ /index.html; }

location /releases { alias /srv/releases; autoindex on; }

location /releases/private { alias /srv/releases/private; auth_basic “Auf zum Atem!!1!”; auth_basic_user_file /etc/nginx/releases_htpasswd; autoindex on; }

  1. hls location /hls { types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; }

alias /tmp/hls; autoindex on; }

  1. stats location /stats/rtmp { rtmp_stat all; allow 127.0.0.1; allow 195.54.164.160/29; # berlin allow 188.40.235.220; # oglarun → meise deny all; }

location /stats/nginx { stub_status on; access_log off; allow 127.0.0.1; allow 195.54.164.160/29; # berlin allow 188.40.235.220; # oglarun → meise deny all; } }

}

rtmp { server { listen [::]:1935 ipv6only=off;

ping 30s;

  1. Disable audio until first video frame is sent. wait_video on;
  2. Send NetStream.Publish.Start and NetStream.Publish.Stop to subscribers. publish_notify on;

  1. Synchronize audio and video streams. If subscriber bandwidth is not
  2. enough to receive data at ublisher rate some frames are dropped by
  3. server. This leads to synchronization problem. When timestamp
  4. difference exceeds the value specified as sync argument an absolute
  5. frame is sent fixing that. Default is 300ms. sync 10ms;

application stream {

  1. enable live streaming live on; meta copy;

hls on; hls_path /tmp/hls; hls_fragment 5;

  1. publish only from localhost allow publish 127.0.0.1; deny publish all;

allow play all; } } } </code>

ffmpeg push: <code> ffmpeg -re -i catcontent.ogg -threads 0 -pix_fmt yuv420p -profile:v baseline -preset fast -tune zerolatency -c:v libx264 -strict -2 -c:a aac -f flv rtmp://localhost:1935/stream/katze </code>

hls

/usr/local/nginx/conf/nginx.conf:

→ siehe Abschnitt hls und http in der rtmp Konfiguration.

ffmpeg push: <code> ffmpeg -re -i catcontent.ogg -threads 0 -pix_fmt yuv420p -profile:v baseline -preset fast -tune zerolatency -c:v libx264 -strict -2 -c:a aac -f flv rtmp://localhost:1935/stream/katze </code>