部署过程

安装相关依赖程序

其中最主要的是ffmpeg,其他的装不装无所谓

apt update -y  && apt upgrade -y && apt install -y curl wget sudo socat htop ffmpeg iftop

编写supervisor守护程序

sudo apt install supervisor
 
#检查是否有可执行权限,如果没有可执行权限,就授予执行权限
cd /etc/init.d/
sudo chmod +x /etc/init.d/supervisor

启动supervisor

sudo service supervisor start   #启动
sudo service supervisor stop	#停止
sudo service supervisor status	#查看状态

编写配置文件

#创建并进入ibeg目录
mkdir /ibeg && cd /ibeg
然后你根据博主的操作,把名为live.mp4的视频上传到ibeg目录
 
#不建议你修改名称
vim /etc/supervisor/conf.d/ibeglive.conf
 
#配置文件内容
[program:ibeglive]
command=ffmpeg -stream_loop -1 -re -i /ibeg/live.mp4 -c copy -f flv rtmp://a.rtmp.youtube.com/live2/wgq1-XXX-XXXXXXX
autostart=true
autorestart=true
startretries=3	
stderr_logfile=/var/log/ffmpeg.err.log
stdout_logfile=/var/log/ffmpeg.out.log

加载配置文件

sudo supervisorctl reread
sudo supervisorctl update

启动服务

supervisorctl start ibeglive
supervisorctl stop ibeglive
supervisorctl status ibeglive
supervisorctl restart ibeglive

人工杀死检测

设置过守护进程之后,人工杀都杀不死程序,杀死自动拉起,非常的好用

kill -9 PID
ps -ef|grep ffmpeg