Our方法
在AWS EC ubuntu 16.04上设置ngnix rtmp Set服务器。成功完成单客户端(RPi摄像机)流。现在,我们希望在这个服务器上发送多个Pi摄像头,该服务器将显示在Android客户端应用程序上。
Problem我们所面临的
我们不能在nginx rtmp服务器上用不同的raspberry Pi 3流多个pi摄像机。当相机websocket不在使用时,我们无法分离它(当相机流关闭时),.We想要将这个可用的websocket分配给另一个相机,它必须为nginx上的流发出一个新的连接请求。
Our期望
我们希望同时设置多个客户端(Raspberry,/Android应用程序用户)的nginx服务器。
Our设置
我们在基于linux的nginx rtmp服务器上的安装配置文件如下所述:
Server侧
#user nobody;
worker_processes 1;
error_log logs/rtmp_error.log debug;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
keepalive_timeout 60s;
server {
listen 80;
server_name 0.0.0.0;
location /stat.xsl {
root /var/www/;
}
location /rtmpstat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
}
}
rtmp {
server {
listen 1935;
buflen 1ms;
application 000000002c23b846 {
live on;
}
application LaoD6Ga59p3qvCTRR5D {
live on;
}
#next
}
}Client侧
#!/bin/sh
YELLOW='\033[1;33m'
RED='\033[0;31m'
SET='\033[0m'
echo "${RED}RTMP${SET}"
echo "${RED}RESOLUTION ${SET}"
read size
else
sudo ssh -i camera_nginx.pem ubuntu@34.221.76.181 "sed -r -i 's|#next|\t\tapplication $1 {\
\n\t\t\t live on;\
\n\t\t}\n\t\t#next|g' /usr/local/nginx/conf/nginx.conf"
fi
if [ $size -eq 1 ]; then
raspivid -n -o - -t 0 -vf -hf -w 1920 -h 1080 -fps 20 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h2$
elif [ $size -eq 2 ]; then
elif [ $size -eq 2 ]; then
raspivid -n -o - -t 0 -vf -hf -w 1920 -h 1080 -fps 20 -b 4000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h2$
elif [ $size -eq 3 ]; then
raspivid -n -o - -t 0 -vf -hf -w 640 -h 480 -fps 20 -b 1000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264$
elif [ $size -eq 4 ]; then
raspivid -n -o - -t 0 -vf -hf -w 640 -h 360 -fps 20 -b 500000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 $
else
echo "Improper resolution"
fi我们使用以下rtmp URL播放视频流:
rtmp://server/cam_id/live
发布于 2019-04-15 08:25:48
请使用rtmp的“exec_kill_signal”命令如下所示。
rtmp {
server {
listen 1935;
chunk_size 4096;
buflen 1ms;
application cam_id {
live on;
allow publish 127.0.0.1;
allow publish all;
allow play all;
record all;
record_path /home/video_recordings;
record_unique on;
hls on;
hls_nested on;
hls_path /home/hls;
hls_fragment 10s;
dash on;
dash_path /home/dash;
dash_nested on;
exec_kill_signal closeStreaming;
}
}
}在客户端程序/应用程序中集成下面的代码以关闭流。
on_die () {
# kill all children
pkill -KILL -P $
}
trap 'on_die' closeStreaminghttps://serverfault.com/questions/961971
复制相似问题