路径:/usr/local/src
nginx-rtmp-module的官方github地址:https://github.com/arut/nginx-rtmp-module
git clone https://github.com/arut/nginx-rtmp-module.git( 如果没有git进行安装,yum install git)
下载 nginx-1.17.0.tar.gz 解压并安装(如果下载不到请自行查找)
wget http://nginx.org/download/nginx-1.17.0.tar.gz解压:
tar -zxvf nginx-1.17.0.tar.gz进入目录:
cd nginx-1.17.0 ./configure --prefix=/usr/local/src/nginx --add-module=../nginx-rtmp-module --with-http_ssl_module make && make install这是我的配置文件,修改了两个地方:
#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; events { worker_connections 1024; } #1----------------------------------------- rtmp { server { listen 1935; chunk_size 4000; application cctvf { live on; hls on; hls_path /usr/local/src/nginx/html/cctvf; hls_fragment 5s; } } } #1end-------------------------------------- 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 85; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #2.---------------------------------------------------- location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /usr/local/src/nginx-rtmp-module/; } #2 end------------------------------------------------- #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; #} } # 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; # } #} }停止:
./usr/local/src/nginx/sbin/nginx -s stop运行:
./usr/local/src/nginx/sbin/nginx用浏览器打开http://ip:85
正常的话,会显示以下页面:
我使用手机推流。涂黑的是服务器IP。1935是端口。cctvf是nginx的application名字。
app可以使用杏林推流。这个app是在应用商店里面搜索推流唯一搜到的结果……
可以把摄像头麦克风推流,也可以推手机屏幕。
推荐使用VLC,因为支持多个平台。菜单媒体 -> 打开网络串流。输入网络URL,缓存推荐使用100ms。
屏幕截图显示不了视频流内容。实际是能显示我的手机屏幕内容的。
1. 利用nginx与nginx-rtmp-module搭建流媒体服务器实现直播 2. ffmpeg+nginx+rtmp+web实现视频直播网站
3. Nginx与Nginx-rtmp-module搭建RTMP视频直播和点播服务器
4. 手把手教你搭建Nginx-rtmp流媒体服务器+使用ffmpeg推流 5. nginx + rtmp 搭建流媒体服务器
6. 利用nginx与nginx-rtmp-module搭建流媒体服务器实现直播 7. NGINX-RTMP直播服务器搭建-OBS录制推流-VLC视频流播放 8. VLC播放器实现推流以及串流的方式
20200725更新两个网址:
9. 一步到位搭建直播推流服务器, https://blog.csdn.net/yingmuliuchuan/article/details/81540263
10. srs(nginx+rtmp 的替代方案), https://github.com/ossrs/srs