Mudanças entre as edições de "Nginx-rtmp-module"

De MochilaWiki
Ir para navegaçãoIr para pesquisar
(Criou página com '<source lang="bash"> apt-get install libgd2-noxpm build-essential devscripts ffmpeg debian-keyring apt-get build-dep nginx apt-get source nginx dpkg-source -x nginx_1.2.1-2.2+...')
 
 
(9 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
 +
O nginx foi instalado num debian 7 e o teste com o ffmpeg/ffplay num Fedora 20
 +
 +
== compilando nginx com módulo rtmp ==
 +
 
<source lang="bash">
 
<source lang="bash">
 
apt-get install libgd2-noxpm build-essential devscripts ffmpeg debian-keyring
 
apt-get install libgd2-noxpm build-essential devscripts ffmpeg debian-keyring
Linha 12: Linha 16:
 
em nginx-1.2.1/debian/rules abaixo de  
 
em nginx-1.2.1/debian/rules abaixo de  
 
  --add-module=$(MODULESDIR)/nginx-dav-ext-module \  
 
  --add-module=$(MODULESDIR)/nginx-dav-ext-module \  
coloque  
+
 
--add-module=$(MODULESDIR)/nginx-rtmp-module \
+
coloque  
 +
--add-module=$(MODULESDIR)/nginx-rtmp-module \
  
 
em  nginx-1.2.1/debian/source/include-binaries acrescente
 
em  nginx-1.2.1/debian/source/include-binaries acrescente
Linha 30: Linha 35:
 
dpkg -i nginx-full_*.deb nginx-common_*.deb  
 
dpkg -i nginx-full_*.deb nginx-common_*.deb  
 
</source>
 
</source>
 +
 +
== configuração do nginx com rtmp e hls ==
 +
 +
altere em /etc/nginx/nginx.conf
 +
 +
<source lang="nginx">
 +
worker_processes  2;
 +
events {
 +
    worker_connections  1024;
 +
}
 +
http {
 +
    access_log /var/log/nginx/access.log;
 +
    error_log /var/log/nginx/error.log;
 +
    include      mime.types;
 +
    default_type  application/octet-stream;
 +
    sendfile        on;
 +
    keepalive_timeout  65;
 +
    server {
 +
        # in case we have another web server on port 80
 +
        listen      8080;
 +
        location /hls {
 +
          types {
 +
            application/vnd.apple.mpegurl m3u8;
 +
            video/mp2t ts;
 +
          }
 +
          #where the m3u8 and ts files are
 +
  #        alias /var/www/hls;
 +
          alias /tmp;
 +
        }
 +
        location / {
 +
            # here we can put our website
 +
            root  /var/www/html;
 +
            index  index.html index.htm;
 +
        }
 +
    }
 +
}
 +
 +
rtmp {
 +
    server {
 +
#        listen 1935;
 +
        listen 80;
 +
 +
        application src {
 +
            live on;
 +
 +
            exec ffmpeg -i rtmp://localhost/src/$name
 +
              -c:a libfdk_aac -b:a 32k  -c:v libx264 -b:v 128K -f flv rtmp://localhost/hls/$name_low
 +
              -c:a libfdk_aac -b:a 64k  -c:v libx264 -b:v 256k -f flv rtmp://localhost/hls/$name_mid
 +
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 512K -f flv rtmp://localhost/hls/$name_hi;
 +
        }
 +
 +
        application hls {
 +
            live on;
 +
 +
            hls on;
 +
            hls_path /tmp/hls;
 +
            hls_nested on;
 +
 +
            hls_variant _low BANDWIDTH=160000;
 +
            hls_variant _mid BANDWIDTH=320000;
 +
            hls_variant _hi  BANDWIDTH=640000;
 +
        }
 +
    }
 +
}
 +
</source>
 +
 +
== teste de envio com ffmpeg ==
 +
 +
<source lang="bash">
 +
ffmpeg -i video-teste.mp4 -c:a copy -c:v copy -f flv rtmp://127.0.0.1/src/sintel
 +
</source>
 +
 +
== assistindo com ffplay ==
 +
<source lang="bash">
 +
ffplay http://localhost/hls/sintel.m3u8
 +
</source>
 +
 +
== forma alternativa de instalação ==
 +
<source lang="bash">
 +
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev unzip
 +
cd /usr/src/
 +
wget http://nginx.org/download/nginx-1.6.2.tar.gz
 +
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
 +
tar -zxvf nginx-1.6.2.tar.gz
 +
unzip master.zip
 +
cd nginx-1.6.2
 +
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
 +
make
 +
make install
 +
ldconfig
 +
wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
 +
chmod +x /etc/init.d/nginx
 +
update-rc.d -f nginx defaults
 +
 +
cat >>/usr/local/nginx/conf/nginx.conf << EOF
 +
rtmp {
 +
        server {
 +
                listen 1935;
 +
                chunk_size 4096;
 +
 +
                application live {
 +
                        live on;
 +
                        record off;
 +
                }
 +
        }
 +
}
 +
EOF
 +
</source>
 +
 +
* http://lowendbox.com/blog/setup-for-streaming-live-events-to-browser-clients-using-nginx-fmle-and-flowplayer/
 +
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=89605
 +
 +
== referências ==
 +
* http://nginx-rtmp.blogspot.com.br/2013/07/hls-variant-playlist.html

Edição atual tal como às 18h48min de 29 de março de 2015

O nginx foi instalado num debian 7 e o teste com o ffmpeg/ffplay num Fedora 20

compilando nginx com módulo rtmp

apt-get install libgd2-noxpm build-essential devscripts ffmpeg debian-keyring
apt-get build-dep nginx
apt-get source nginx
dpkg-source -x nginx_1.2.1-2.2+wheezy2.dsc
wget https://github.com/arut/nginx-rtmp-module/archive/v1.1.2.tar.gz
tar xvzf v1.1.2.tar.gz
mkdir nginx-1.2.1/debian/modules/nginx-rtmp-module
cp -r nginx-rtmp-module-1.1.2/*  nginx-1.2.1/debian/modules/nginx-rtmp-module

em nginx-1.2.1/debian/rules abaixo de

--add-module=$(MODULESDIR)/nginx-dav-ext-module \ 

coloque

--add-module=$(MODULESDIR)/nginx-rtmp-module \

em nginx-1.2.1/debian/source/include-binaries acrescente

debian/modules/nginx-rtmp-module/test/rtmp-publisher/RtmpPlayer.swf
debian/modules/nginx-rtmp-module/test/rtmp-publisher/RtmpPublisher.swf
debian/modules/nginx-rtmp-module/test/rtmp-publisher/RtmpPlayerLight.swf
debian/modules/nginx-rtmp-module/test/www/bg.jpg
debian/modules/nginx-rtmp-module/test/www/jwplayer_old/player.swf
debian/modules/nginx-rtmp-module/test/www/jwplayer/jwplayer.flash.swf

e depois

cd nginx-1.2.1/
dpkg-buildpackage -rfakeroot -b
cd /usr/src/
dpkg -i nginx-full_*.deb nginx-common_*.deb

configuração do nginx com rtmp e hls

altere em /etc/nginx/nginx.conf

worker_processes  2;
events {
    worker_connections  1024;
}
http {
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        # in case we have another web server on port 80
        listen       8080;
        location /hls {
          types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
          }
          #where the m3u8 and ts files are
  #        alias /var/www/hls;
          alias /tmp;
        }
        location / {
            # here we can put our website
            root   /var/www/html;
            index  index.html index.htm;
        }
    }
}

rtmp {
    server {
#        listen 1935;
         listen 80;

        application src {
            live on;

            exec ffmpeg -i rtmp://localhost/src/$name
              -c:a libfdk_aac -b:a 32k  -c:v libx264 -b:v 128K -f flv rtmp://localhost/hls/$name_low
              -c:a libfdk_aac -b:a 64k  -c:v libx264 -b:v 256k -f flv rtmp://localhost/hls/$name_mid
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 512K -f flv rtmp://localhost/hls/$name_hi;
        }

        application hls {
            live on;

            hls on;
            hls_path /tmp/hls;
            hls_nested on;

            hls_variant _low BANDWIDTH=160000;
            hls_variant _mid BANDWIDTH=320000;
            hls_variant _hi  BANDWIDTH=640000;
        }
    }
}

teste de envio com ffmpeg

ffmpeg -i video-teste.mp4 -c:a copy -c:v copy -f flv rtmp://127.0.0.1/src/sintel

assistindo com ffplay

ffplay http://localhost/hls/sintel.m3u8

forma alternativa de instalação

apt-get install build-essential libpcre3 libpcre3-dev libssl-dev unzip
cd /usr/src/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
tar -zxvf nginx-1.6.2.tar.gz
unzip master.zip
cd nginx-1.6.2
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make
make install
ldconfig
wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
chmod +x /etc/init.d/nginx
update-rc.d -f nginx defaults

cat >>/usr/local/nginx/conf/nginx.conf << EOF
rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                }
        }
}
EOF

referências