Skip to content

Instantly share code, notes, and snippets.

@sumonst21
Created July 16, 2019 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumonst21/f585dd11e9d85272f92c2b6777bd8438 to your computer and use it in GitHub Desktop.
Save sumonst21/f585dd11e9d85272f92c2b6777bd8438 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