Skip to content

Instantly share code, notes, and snippets.

@gcnonato
Created July 14, 2018 15:52
Show Gist options
  • Save gcnonato/dbf52502d47ce20d183618fb52baa070 to your computer and use it in GitHub Desktop.
Save gcnonato/dbf52502d47ce20d183618fb52baa070 to your computer and use it in GitHub Desktop.
Nginx transcode example using ffmpeg and two applications
#user nobody;
worker_processes 1;
error_log logs/rtmp_error.log debug;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
allow all;
deny all;
access_log logs/rtmp_access.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
# rtmp stat
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# you can move stat.xsl to a different location
root html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 8192;
application origin {
live on;
meta copy;
exec ffmpeg -i rtmp://localhost/origin/$name -c:v libx264 -c:a copy -s 640x480 rtmp://localhost/live/480p_$name;
exec ffmpeg -i rtmp://localhost/origin/$name -c:v libx264 -c:a copy -s 320x240 rtmp://localhost/live/240p_$name;
exec ffmpeg -i rtmp://localhost/origin/$name -c:v libx264 -c:a copy -s 160x120 rtmp://localhost/live/120p_$name;
}
application live {
live on;
meta copy;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment