我想在Debian机器上使用 nginx+rtmp module 重新启动网络摄像头 . 当我重新调整一个凸轮时,它工作得很好而且流畅,但它占用了很多CPU:
这是我的配置:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
}
rtmp_auto_push on;
rtmp {
live on;
hls on;
hls_fragment 5s;
respawn_timeout 15s;
chunk_size 8192;
server {
listen 1935;
application cam1 {
hls_path /tmp/cam1;
}
exec_static /usr/bin/ffmpeg -i http://cam-ip:8080/flv?login=user&channelid=channalid&password=pass&count=0
-acodec copy -vcodec libx264 -vprofile baseline -f flv rtmp://server-ip/cam1/stream;
}
}
http {
server {
listen 8080;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location stat.xsl {
root /stat;
}
location / {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp/;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}
}
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
}
之后我在配置中添加了12个网络摄像头,当我看到凸轮时,我得到了可怕的滞后 . 并且100%的CPU使用率:
为什么我在htop中有这么多的ffmpeg进程?
为什么需要这么多CPU呢?