[英]Fail to restream with nginx-rtmp-module
I'm unable to start restream using command exec
. 我无法使用命令exec
开始重播。 Also I tried exec_pull
. 我也尝试了exec_pull
。 It didn't help. 它没有帮助。 My target is to restream rtmp://ktv.s4c.link/live/livestream
url to my local nginx, to rtmp://localhost:1935/hls
. 我的目标是将rtmp://ktv.s4c.link/live/livestream
url重新rtmp://ktv.s4c.link/live/livestream
我的本地nginx,再到rtmp://localhost:1935/hls
。 /tmp/logs/ffmpeg.log
is empty. /tmp/logs/ffmpeg.log
为空。 I guess that exec
not even called, but why? 我猜那个exec
甚至都没有打电话,但是为什么呢?
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
allow play all;
live on;
record off;
#pull rtmp://ktv.s4c.link/live/livestream;
exec ffmpeg -i rtmp://localhost:1935/live -f flv rtmp://localhost:1935/hls 2>>/tmp/logs/ffmpeg.log;
}
application hls {
allow play all;
live on;
record off;
}
}
I'm using nginx-1.12.0. 我正在使用nginx-1.12.0。 I followed by this tutorial , watched this 我跟随本教程 ,观看了
So, first of all, be aware of that Nginx run all your exec commands as nobody
user. 因此, 首先 ,请注意Nginx以nobody
用户身份运行所有exec命令。 And you have to test it in command line like this: 而且您必须像这样在命令行中对其进行测试:
sudo -u nobody ffmpeg -i rtmp://ktv.s4c.link/live/livestream -f flv rtmp://localhost:1935/hls
And then if this command line works - print to nginx.conf. 然后,如果此命令行有效-打印到nginx.conf。
Secondly , use the full path. 其次 ,使用完整路径。 It's very important , because a child process than Nginx runs has different environment compared with your current user environment. 这非常重要 ,因为与Nginx运行的子进程相比,当前的用户环境具有不同的环境。
sudo -u nobody /usr/bin/ffmpeg -i rtmp://ktv.s4c.link/live/livestream -f flv rtmp://localhost:1935/hls
Thirdly , my mistake was that I used FFmpeg from the repository and that FFmpeg has 2.8.11-0ubuntu0.16.04.1
version. 第三 ,我的错误是我从存储库中使用了FFmpeg,并且FFmpeg具有2.8.11-0ubuntu0.16.04.1
版本。 Related to this answer FFmpeg can be compiled with librtmp , that's why FFmpeg can require live=1 and quotes( " ). So the final command that I copied to nginx.conf was: 与此相关的答案 FFmpeg的可被编译librtmp ,这就是为什么FFmpeg的可能需要现场= 1和引号(“)所以最后,我复制到nginx.conf是命令:
sudo -u nobody /usr/bin/ffmpeg -i "rtmp://ktv.s4c.link/live/livestream live=1" -f flv rtmp://localhost:1935/hls
My final nginx.conf 我最后的nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
pull rtmp://ktv.s4c.link/live/livestream;
exec_play /usr/bin/ffmpeg -i "rtmp://ktv.s4c.link/live/livestream live=1" -f flv rtmp://localhost:1935/hls 2>>/tmp/ffmpeg-$name.log;
}
application hls {
live on;
record off;
}
}
As you can mention I added FFmpeg logs 2>>/tmp/ffmpeg-$name.log
. 您可以提及,我添加了FFmpeg日志2>>/tmp/ffmpeg-$name.log
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.