Nginx + Rtmp 는 rtmp 와 HLS 생방송 흐름 을 실현 하 는 동시에 시간 이동 (세그먼트 녹화 재생) 기능 을 실현 합 니 다.
#!/bin/sh
if [ $(id -u) != "0" ]; then
echo "Error: Please use root role to install!"
exit 1
fi
clear
echo "========================================"
echo ""
echo "========================================"
echo "======= nginx_rtmp one key sctipt ======"
echo "========================================"
echo ""
echo "========================================"
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
#echo "Press any key to start...or Press Ctrl+c to cancel"
#char=`get_char`
echo "========================================"
echo "Start install nginx_rtmp ..."
echo "========================================"
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
cur_dir=$(pwd)
cd nginx-1.8.0
echo "========================================"
echo "configure start ..."
echo "========================================"
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--error-log-path=/usr/local/nginx/logs/error.log \
--add-module=../nginx-rtmp-module \
--with-http_mp4_module
echo "========================================"
echo "make &install"
echo "========================================"
make
make install
echo "========================================"
echo "Setting start"
echo "========================================"
cd $cur_dir
\cp nginx.conf /usr/local/nginx/
\cp nginx-rtmp-module/stat.xsl /usr/local/nginx/html/
\cp nginx /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
service nginx start
echo "Service Test:"
echo "service nginx status"
echo "Result:"
service nginx status
#cat > /etc/fstab <> /etc/rc.d/rc.local
echo "========================================"
echo "Firewall config"
echo "========================================"
iptables -I INPUT -p tcp --dport 6080 -j ACCEPT
iptables -I INPUT -p tcp --dport 5080 -j ACCEPT
iptables -I INPUT -p tcp --dport 1935 -j ACCEPT
service iptables save
echo "========================================"
echo "Install end."
echo "========================================"
nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
#pid logs/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 1024;
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
max_connections 1024;
}
application hls {
live on;
hls on;
hls_path /usr/local/nginx/html/app;
hls_fragment 3s;
hls_playlist_length 30s;
hls_sync 100ms;
meta copy;
recorder chunked {
record all;
#record_max_size 6200K;
record_interval 10s;
record_suffix -%Y-%m-%d-%H_%M_%S.flv;
record_path /data/www/Upload/Rec/Chunked;
}
recorder all {
record all;
record_suffix -%Y-%m-%d-%H_%M_%S.flv;
record_max_size 6200000K;
record_path /data/www/Upload/Rec;
}
}
application Upload {
play /data/www/Upload;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 5080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location /hls {
types {
#application/vnd.apple.mpegurl m3u8;
application/x-mpegurl m3u8;
video/mp2t ts;
}
alias /usr/local/nginx/html/app;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root html;
}
}
server {
listen 6080;
server_name localhost;
location / {
root /data/www/AVA.ResourcesPlatform.AdminUI;
index index.html index.htm;
mp4;
mp4_buffer_size 1m;
mp4_max_buffer_size 5m;
#mp4_limit_rate on;
#mp4_limit_rate_after 30s;
limit_rate 1m; # about 2mbit
limit_rate_after 5m;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#location ~ \.mp4$ {
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
다음으로 전송:https://www.cnblogs.com/JerryBaxia/p/4776299.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.