我正在使用一个非常简单的程序将ffmpeg流从我的树莓派相机推送到nginx服务器。但是,在90分钟后,我使用的几乎每一个Raspberry Pi都失败了(我在12个Raspberry Pi上都有此代码)。 这是我的ffmpeg命令:
raspivid -o - -t 0 -w 640 -h 480 -fps 25 | ffmpeg -re -i - -vcodec copy -hls_time 4 -f hls -hls_list_size 5 -hls_wrap 5 -threads 0 -timeout 5000 -max_reload 20000 -method PUT http://{}:{}/live/{}
这是我对nginx.conf的配置:
#user nobody;
load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
worker_processes auto;
env CONTROL_SERVER_IP;
#error_log /var/log/nginx/error.log;
error_log /dev/stdout info;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
sendfile on;
keepalive_requests 100000;
keepalive_timeout 30;
client_max_body_size 10M;
server {
listen 80;
server_name localhost;
location /live {
root /var/static;
client_body_temp_path /var/static/client_temp;
dav_methods PUT;
create_full_put_path on;
dav_access user:rw group:r all:r;
types {
application/vnd.apple.mpegurl m3u8;
}
# Disable Cache
add_header Cache-Control no-cache;
include cors.conf;
}
}
}
daemon off;
如果有人可以帮助我,我将深表感谢。我一直在努力解决这个错误。在树莓派上,它挂在上面:
[hls @ 0x25a8c90] Opening 'http://192.168.8.1:80/live/c35d8935-0a31-4d22-b71a-ad3f4f1d47631.ts' for writing
frame=105609 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105518 speed=1.02xframe=105623 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105532 speed=1.02xframe=105636 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105545 speed=1.02xframe=105648 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105557 speed=1.02xframe=105662 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105571 speed=1.02xframe=105674 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105583 speed=1.02xframe=105688 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105597 speed=1.02xframe=105700 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105609 speed=1.02xframe=105714 fps= 25 q=-1.0 q=1.6 size=N/A time=01:11:40.00 bitrate=N/A dup=0 drop=105623 speed=1.02x[hls muxer @ 0x25a9200] Duplicated segment filename detected: c35d8935-0a31-4d22-b71a-ad3f4f1d47631.ts
[hls @ 0x25a8c90] Opening 'http://192.168.8.1:80/live/c35d8935-0a31-4d22-b71a-ad3f4f1d47632.ts' for writing
在nginx日志上,我得到:
192.168.10.242 - - [21/Oct/2018:22:34:01 +0000] "PUT /live/c35d8935-0a31-4d22-b71a-ad3f4f1d4763.m3u8 HTTP/1.1" 204 0 "-" "Lavf/57.83.100"
192.168.10.242 - - [21/Oct/2018:22:35:04 +0000] "PUT /live/c35d8935-0a31-4d22-b71a-ad3f4f1d47633.ts HTTP/1.1" 408 0 "-" "Lavf/57.83.100"
我需要建立一种方法来要么a)保持一致的连接超过90分钟,要么b)检测408错误何时发生并将其挂起。
FFMPEG版本:3.4.1