Windows预编译版下载地址
http://nginx-win.ecsds.eu/download/
http://nginx-win.ecsds.eu/download/nginx%201.7.11.3%20Gryphon.zip
直接安装即可,不做赘述
yamdi
简介
yamdi用于为rtmp点播文件添加索引
下载
http://yamdi.sourceforge.net/
https://github.com/ioppermann/yamdi/releases
编译
1 2
| gcc yamdi.c -o yamdi -O2 -Wall cp yamdi /usr/local/bin
|
nginx-rtmp
编译安装
1 2 3
| ./configure --prefix=/opt/nginx-rtmp --with-openssl=../openssl-1.1.1g --add-module=../nginx-rtmp-module-1.2.1 --with-debug make make install
|
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| worker_processes 1;
error_log logs/error.log debug;
events { worker_connections 1024; }
rtmp { server { listen 1935;
application hls { live on; hls on; hls_path nginx-rtmp-module/tmp/app/; hls_fragment 5s; recorder rec { record all manual; record_suffix _rec.flv; record_path nginx-rtmp-module/tmp/rec/; record_unique on; } } application vod2{ play nginx-rtmp-module/tmp/rec/; } } }
http { server { listen 18080;
location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; }
location /stat.xsl { root nginx-rtmp-module/; }
location /control { rtmp_control all; } location /hls/ { types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } alias nginx-rtmp-module/tmp/app/; expires -1; }
location /vod/{ alias nginx-rtmp-module/tmp/rec/; }
location / { root nginx-rtmp-module/test/www/; } } }
|
注意拷贝stat.xsl到相应目录下
测试
rtmp监控
http://localhost:18080/stat
rtmp推流
地址:
rtmp://10.30.22.242:1935/hls/mystream
rtmp直播
rtmp://127.0.0.1:1935/hls/mystream
hls直播
http://127.0.0.1:18080/hls/mystream.m3u8
录制视频
http://127.0.0.1:18080/control/record/start?app=hls&name=mystream&rec=rec
http://127.0.0.1:18080/control/record/stop?app=hls&name=mystream&rec=rec
为rtmp点播文件添加索引
1 2
| cd /tmp/rec yamdi -i mystream-1597303714_rec.flv -o mystream-1597303714_rec_idx.flv
|
rtmp点播
rtmp://127.0.0.1:1935/vod2/mystream-1597303714_rec_idx.flv
制作hls点播分片文件
1 2 3 4 5
| cd nginx-rtmp/nginx-rtmp-module/tmp/rec
ffmpeg -i mystream-1597303714_rec.flv -acodec copy -bsf:a h264_mp4toannexb -g 105 -vcodec libx264 -vprofile baseline -bf 0 -bufsize 850k -bsf:v dump_extra -map 0 -f segment -segment_format mpegts -segment_list "mystream-1597303714_rec.m3u8" -segment_time 10 mystream-1597303714_rec-%d.ts
ffmpeg -i mystream-1597303714_rec.flv -acodec copy -bsf:a aac_adtstoasc -g 105 -vcodec libx264 -vprofile baseline -bf 0 -bufsize 850k -bsf:v dump_extra -map 0 -f segment -segment_format mpegts -segment_list "mystream-1597303714_rec.m3u8" -segment_time 10 mystream-1597303714_rec-%d.ts
|
hls点播
http://127.0.0.1:18080/vod/mystream-1597303714_rec.m3u8