一、rtmp服务器搭建
环境:
ubuntu
1.先安装docker(省略)
2.下载docker容器
docker pull tiangolo/nginx-rtmp
3.运行容器(记得打开防火墙端口 1935和9090)
docker run -tid --name myrtmp -p 1935:1935 -p 9090:80 -v /opt/nginx:/etc/nginx:rw tiangolo/nginx-rtmp
4.进入到容器内部,修改nginx配置
docker exec -ti myrtmp /bin/bash
apt-get install vim
vim nginx.config
若没有vim命令:
则在容器中安装vim
apt-get install vim
如果报错:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vim
这个时候需要跟新apt-get: 然后进行安装
apt-get update
修改nginx配置如下:
worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
server {
listen 1935;
listen [::]:1935 ipv6only=on;
application live {
live on;
record off;
}
application hls {
live on;
hls on;
hls_path temp/file; #视频流存放地址
hls_fragment 3s;
hls_playlist_length 3s;
hls_continuous on; #连续模式
hls_cleanup off; #对多余的切片进行删除。
hls_