Tutorial RTMP
Tutorial RTMP
FFMPEG ]
-----------------------------------------------------------------------------------------------------
wget http://nginx.org/download/nginx-1.12.2.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.tar.gz
rm nginx-1.12.2.tar.gz
rm master.tar.gz
----------------------------------------------------------------------------------------------------
cd nginx-1.12.2
make
----------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
user www-data;
worker_processes 1;
events {
worker_connections 1024;
}
# http requests allow checking that rtmp is working and being published to
http {
# turn off server tokens and hide what server version you are using
server_tokens off;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
# allow publishing from all (change this to your ip if you wish to lock to ip address)
allow publish all;
# uncomment this if you are going to deny every ip other than yours
# deny publish all;
# push to all sub applications we will create (one each for each application)
push rtmp://localhost/youtube;
push rtmp://localhost/facebook;
push rtmp://localhost/mixer;
# for twitch I'm being more specific so I can define how my stream looks on twitch
exec ffmpeg -i rtmp://localhost/$app/$name -c:v libx264 -preset veryfast -c:a copy
-b:v 3500k
-bufsize 3500k
-maxrate 3500k
-s 1280x720 -r 30
-f flv rtmp://localhost/twitch/$name;
}
# push url, this will be your stream url and stream key together
push rtmp://{youtube-stream-url};
}
# push url, this will be your stream url and stream key together
push rtmp://{twitch-stream-url};
}
application facebook {
live on;
record off;
# push url, this will be your stream url and stream key together
push rtmp://{facebook-stream-url};
application mixer {
live on;
record off;
# push url, this will be your stream url and stream key together
push rtmp://{mixer-stream-url};
}
}
}
-Reiniciando o nginx
---------------------------------------------------------------------------------------------------
ffmpeg -i [entrada] -b:v 3M -b:a 128k -vcodec libx264 -pix_fmt yuv420p -acodec copy -ar 44100 -s
1280x720 -preset ultrafast -framerate 30 -g 60 -f flv [ponto de saida]
---------------------------------------------------------------------------------------------------
Para transmitir para varios sites basta configurar o exemplo do PASSO 06 com as chaves de cada
sistema e manda o obs entregar os fluxos no ponto rtmp://ip/live lembrando que o servidor precisa
permitir entrada na porta do rtmp que por padrão é 1935
---------------------------------------------------------------------------------------------------