docker-compose
version: '2'
services:
szmx:
container_name: szmx
image: alqutami/rtmp-hls
restart: always
ports:
- '1935:1935'
- '1945:8080'
environment:
- TZ=Asia/Shanghai
volumes:
- ./nginx/logs:/var/log/nginx
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/html:/usr/share/nginx/html
镜像说明(alqutami/rtmp-hls)
这是一个基于 Nginx 和 nginx-rtmp-module 的模块
使用 FFmpeg 来转码和自适应流媒体
默认配置
RTMP open
HLS open(适配5种变量)
DASH open
统计页面 http://<server ip>:<server port>/stats
基于video.js和hls.js的web视频播放器,被放在 /usr/local/nginx/html/players 下面
该镜像使用如下模块编译
Nginx 1.17.5
Nginx-rtmp-module 1.2.1
FFmpeg 4.2.1
镜像的配置文件 nginx.conf 在 Github 上,可以参考着改 https://github.com/TareqAlqutami/rtmp-hls-server/blob/master/conf/nginx.conf
推送流
RTMP的实时流可以推送到如下地址
rtmp://<server ip>:1935/live/<stream_key>
其中 stream_key 可以是你指定的任何关键字
启动容器
推流
rtmp协议的默认端口是1935,如果启动容器的时候替换成了别的端口,需要在rtmp的地址后面跟上端口,除此之外,其他都一样
默认端口
ffmpeg -re -stream_loop -1 -i /home/chen/Desktop/QQ视频20200524211316.mp4 -vcodec copy -acodec copy -f flv -y rtmp://127.0.0.1/live/test
自定义端口
ffmpeg -re -stream_loop -1 -i /home/chen/Desktop/QQ视频20200524211316.mp4 -vcodec copy -acodec copy -f flv -y rtmp://127.0.0.1:11935/live/test
播放
默认端口
ffplay rtmp://127.0.0.1/live/test
自定义端口
ffplay rtmp://127.0.0.1:11935/live/test