User Tools

Site Tools


Sidebar

Eventsupport

Sponsors

Interested in supporting an Open Source Camp? Get in touch: unfuck[at]unfuck[dot]eu

Predecessors

$RANDOM

archive:2014:nginx-streaming

nginx streaming

Debian 7 (hub)

/etc/nginx/rtmp.conf
rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application unfuck {
            live on;
            allow publish FIXME;
            deny publish all;
            allow play all;
        }

    }
}

Debian 7 (onsite)

aptitude -y install vim screen build-essential git subversion autotools-dev debhelper libexpat-dev libgd2-noxpm-dev libgeoip-dev liblua5.1-dev libmhash-dev libpam0g-dev libpcre3-dev libperl-dev libssl-dev libxslt1-dev po-debconf zlib1g-dev
mkdir /usr/src/nginx
cd /usr/src/nginx
apt-get source nginx
git clone https://github.com/arut/nginx-rtmp-module.git
cd nginx-1.2.1
patch debian/rules < rtmp.patch
dpkg-buildpackage -b
cd ..
dpkg -i nginx-full_1.2.1-2.2+wheezy2_amd64.deb nginx-common_1.2.1-2.2+wheezy2_all.deb
cp /usr/src/nginx/nginx-rtmp-module/stat.xsl /var/lib/nginx/
rtmp.patch
--- debian/rules.org    2014-03-22 16:34:46.868210607 +0100
+++ debian/rules        2014-03-22 16:35:04.080204053 +0100
@@ -88,6 +88,7 @@
            --add-module=$(MODULESDIR)/nginx-echo \
            --add-module=$(MODULESDIR)/nginx-upstream-fair \
            --add-module=$(MODULESDIR)/nginx-dav-ext-module \
+           --add-module=/usr/src/nginx/nginx-rtmp-module \
             $(CONFIGURE_OPTS) >$@
        touch $@
/etc/nginx/sites-enabled/rtmp
server {
        listen 8080;
        server_name foostream.unfuck.eu;

        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            root /var/lib/nginx;
        }
}
nginx.conf.patch
--- nginx.conf.org      2013-11-20 00:14:01.000000000 +0100
+++ nginx.conf  2014-03-22 17:07:43.908211649 +0100
@@ -73,6 +73,8 @@
 }


+include /etc/nginx/rtmp.conf;
+
 #mail {
 #      # See sample authentication script at:
 #      # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
/etc/nginx/rtmp.conf
rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application unfuck {
            live on;
            allow publish 10.0.50.0/24;
            deny publish all;
            allow play all;

            push rtmp://141.28.77.155/unfuck/live;

            recorder rec1 {
                record all;
                record_max_size 1024M;
                record_path /usr/share/nginx/www/record;
		record_suffix -%Y%m%d-%T.flv;
                record_unique on;
            }

        }

    }
}

Ubuntu 12.04 LTS (onsite/dev)

sudo su
aptitude install git subversion build-essential libpcre3-dev libssl-dev

dann https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp

cd /usr/build
git clone git://github.com/arut/nginx-rtmp-module.git
wget http://nginx.org/download/nginx-1.4.6.tar.gz
tar xzf nginx-1.4.6.tar.gz
cd nginx-1.4.6
./configure --add-module=/usr/build/nginx-rtmp-module --with-http_ssl_module
make
make install

nginx.conf anpassen:

worker_processes  1;
error_log  logs/error.log  info;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  name.eu;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            root /usr/build/nginx-rtmp-module;
            #FIXME
            allow 127.0.0.1;
        }

# location /control { # rtmp_control all; # allow 127.0.0.1; # }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;
        application live {
            live on;
            allow publish 10.0.50.0/24;
            deny publish all;
            allow play all;
            recorder rec1 {
                record all;
                record_max_size 1024M;
                record_path /usr/local/nginx/html/record;
                record_suffix -%Y%m%d-%T.flv;
                record_unique on;
            }
        }
    }
}

/etc/init/nginx.conf gemäss http://wiki.nginx.org/Upstart erstellen, danach

initctl list | grep nginx && initctl start nginx
# nginx

description "nginx http daemon"
author "George Shammas <georgyo@gmail.com>"

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]

env DAEMON=/usr/local/nginx/sbin/nginx
env PID=/usr/local/nginx/logs/nginx.pid

expect fork
respawn
respawn limit 10 5
#oom never

pre-start script
        $DAEMON -t
        if [ $? -ne 0 ]
                then exit $?
        fi
end script

exec $DAEMON

Client/Sender

Streaming von Firewire

dvgrab --format raw - | ffmpeg -re -i - -deinterlace -an -c:v libx264 -f flv rtmp://141.28.77.155/unfuck/live

Von https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp:

Streaming and encoding audio (AAC) and video (H264), need libx264 and libfaac

ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libfaac -ar 44100 -ac 1 -f flv rtmp://141.28.77.155/unfuck/live

Streaming and encoding audio (MP3) and video (H264), need libx264 abd libmp3lame

ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libmp3lame -ar 44100 -ac 1 -f flv rtmp://141.28.77.155/unfuck/live

Streaming and encoding audio (Nellymoser) and video (Sorenson H263)

ffmpeg -re -i /var/Videos/test.mp4 -c:v flv -c:a nellymoser -ar 44100 -ac 1 -f flv rtmp://141.28.77.155/unfuck/live

Publishing video from webcam

ffmpeg -f video4linux2 -i /dev/video0 -c:v libx264 -an -f flv rtmp://141.28.77.155/unfuck/live
archive/2014/nginx-streaming.txt · Last modified: 2015/01/14 07:54 by luke