nginx-rtmp-module
nginx-rtmp-module copied to clipboard
i have problem, the nginx use "exec ffmpeg" is not working
Generated by nginx-rtmp-module 1.1.4, nginx 1.18.0 use root run the nginx server
I use OBS for push streaming (rtmp://server/push); I use VLC player to play;
I want to achieve like "RTMP -> ffmpeg -> RTMP"
this is my nginx config;
rtmp {
server {
listen 1935;
chunk_size 4096;
ping 3m;
ping_timeout 30s;
application push {
live on;
#push rtmp://localhost/live; is work!
exec /usr/bin/ffmpeg -i rtmp://localhost/push/$name -f flv rtmp://localhost/live; # it's not work!
# exec /usr/bin/ffmpeg -i rtmp://localhost/push -f flv rtmp://localhost/live; it's not work!
# exec /usr/bin/ffmpeg -i rtmp://localhost/push/$name -f flv rtmp://localhost/live/$name; it's not work!
}
application live {
live on;
}
}
}
the VLC url is rtmp://server/live; but can not play video;
i use the config. can print log,but the VLC not play video;
exec_push /usr/bin/ffmpeg -i rtmp://localhost/push/$name -f flv rtmp://localhost/live/$name 2>>/usr/local/nginx/logs/ffmpeg-$name.log
log file:
tail -f -n 200 ../logs/ffmpeg-srv.log
ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
try: exec /usr/bin/ffmpeg -i rtmp://localhost/push/$name -f flv rtmp://localhost/live/$name
try: exec /usr/bin/ffmpeg -i rtmp://localhost/push/$name -f flv rtmp://localhost/live/$name
thank you for your reply but is not work
it can be releated with parameters,
exec /usr/bin/ffmpeg -i rtmp://localhost/push/$name -c copy -f flv rtmp://localhost/live/$name
normaly rtmp strusture is rtmp://IP_ADRESS:1935/aplication/endpoint in your case you have wrong endpoint this why it can't work . why sending input stream specify a name of your endpoint explicitly and then do
exec /usr/bin/ffmpeg -i rtmp://IP_ADRESS:1935/push/endpoint -c copy -f flv rtmp://IP_ADRESS:1935/live/new_endpoint
something litle bit complexe but very efficient is to write a php script or bash script to do it
and call exec php your_php_file_srcipt.php for example
in your nginx conf file
try :
user root;
worker_processes 1;
......
try :
user root;
worker_processes 1; ......
thank you for your reply but is not work
Are you running Nginx in a Docker container?
Confirm you can run ffmpeg with '/usr/bin/ffmpeg -codecs' Docker does not play well with localhost so just use the IP equivalent.
exec /usr/bin/ffmpeg -i rtmp://127.0.0.1/push/$name -f flv rtmp://127.0.0.1/live;
I can not solve this problem too....................
@liyang142 Did you solve this problem? I have the same problem with you?
通常rtmp的信任是rtmp:// IP_ADRESS:1935 / aplication / endpoint在你的情况下你有错误的端点,这就是为什么它不起作用的原因。为什么发送输入流显式指定端点的名称, 然后执行
exec /usr/bin/ffmpeg -i rtmp://IP_ADRESS:1935/push/endpoint -c copy -f flv rtmp://IP_ADRESS:1935/live/new_endpoint
有点复杂但非常有效的方法是编写一个php脚本或bash脚本来执行此操作, 然后调用
exec php your_php_file_srcipt.php for example
您的nginx conf文件
I tried the .sh file you mentioned, but the ffmpeg command is still not executed ffmpeg.sh: ffmpeg -re -i rtmp://ip:1936/myapp/$name -acodec copy -c:v libx264 -preset veryfast -profile:v baseline -vsync cfr -s 480x360 -b:v 400k -bufsize 400k -threads 0 -r 30 -f flv rtmp://ip:1936/myapp/test> /usr/local/erro/log.txt;
use script
exec_push /tmp/script.sh $name;
#!/bin/bash eval ffmpeg -i rtmp://localhost:port/$1
这个问题我也遇到了,是因为 nginx的 worker进程是没有指定用户的,所以找不到ffmepg这个东西
你可以参照官网 使用,打印出日志来看看就知道为什么了 application src { live on; exec_push ffmpeg -i rtmp://localhost/src/$name -vcodec libx264 -vprofile baseline -g 10 -s 300x200 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls/$name 2>>/var/log/ffmpeg-$name.log; }
application hls { live on; hls on; hls_path /tmp/hls; hls_fragment 15s; }