Last active
July 7, 2023 08:02
-
-
Save iflamed/406f73d7aae01ca2cec2b6cca4f4384d to your computer and use it in GitHub Desktop.
How to use nginx as RTMP server?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create rtmp stream from video | |
ffmpeg -stream_loop -1 -i test02.mp4 -c:a copy -c:v libx264 -f flv rtmp://www.example.com/mytv/test02 | |
ffmpeg -stream_loop -1 -i test02.mp4 -f flv rtmp://www.example.com/mytv/test02 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /hls { | |
# Serve HLS fragments | |
types { | |
application/vnd.apple.mpegurl m3u8; | |
video/mp2t ts; | |
} | |
root /tmp; | |
add_header Cache-Control no-cache; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load_module modules/ngx_rtmp_module.so; | |
rtmp { | |
access_log /var/log/nginx/rtmp_access.log; | |
server { | |
listen 1935; | |
chunk_size 4000; | |
# TV mode: one publisher, many subscribers | |
application mytv { | |
# enable live streaming | |
live on; | |
hls on; | |
hls_path /tmp/hls; | |
# publish only from localhost | |
allow publish all; | |
allow play all; | |
# publish directly by nginx | |
exec_static ffmpeg -stream_loop -1 -i /var/www/test_hls_rtmp.mp4 -c:a copy -c:v libx264 -f flv rtmp://localhost:1935/mytv/test02; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment