nginx?搭建http-flv(rtmp)流媒體的方法步驟
git地址
https://github.com/winshining/nginx-http-flv-module/blob/master/README.CN.md
下載nginx-flv模塊
git clone https://github.com/arut/nginx-http-flv-module
安裝nginx依賴
yum -y install openssl openssl-devel
安裝nginx
wget http://nginx.org/download/nginx-1.10.3.tar.gz? tar -zxvf nginx-1.10.3.tar.gz? cd nginx-1.10.3 //添加rtmp和openssl支持 ./configure --add-module=/絕對路徑/nginx-http-flv-module --with-http_ssl_module make && make install
配軟鏈接
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/
啟動nginx
nginx 啟動 nginx -s reload 重啟 nginx -s stop 停止
配置流媒體
vim /usr/local/nginx/conf/nginx.conf
#user ?nobody;
worker_processes ?4;
#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;
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp {
? ? out_queue ? ? ? ? ? 4096;
? ? out_cork ? ? ? ? ? ?8;
? ? max_streams ? ? ? ? 128;
? ? timeout ? ? ? ? ? ? 15s;
? ? drop_idle_publisher 15s;
? ? log_interval 5s; #log 模塊在 access.log 中記錄日志的間隔時間,對調(diào)試非常有用
? ? log_size ? ? 1m; #log 模塊用來記錄日志的緩沖區(qū)大小
? ? ?server {
? ? ? ? listen 54321 reuseport;
? ? ? ? server_name _;
? ? ? ? application myapp {
? ? ? ? ? ? live on;
? ? ? ? ? ? meta off;# 為了兼容網(wǎng)頁前端的 flv.js,設置為 off 可以避免報錯
? ? ? ? ? ? gop_cache on; # 支持GOP緩存,以減少首屏時間
? ? ? ? ? ? allow play all; # 允許來自任何 ip 的人拉流
? ? ? ? }
? ? }
}?? ?
http {
? ? include ? ? ? mime.types;
? ? default_type ?application/octet-stream;
? ? keepalive_timeout ?65;
? ? server {
? ? ? ? listen ? ? ? 80;
? ? ? ? server_name ?_;
? ? ? ? location /live {
? ? ? ? ? ? flv_live on;
? ? ? ? ? ? chunked_transfer_encoding on; #支持'Transfer-Encoding: chunked'方式回復?
? ? ? ? ? ? add_header 'Access-Control-Allow-Origin' '*'; #添加額外的 HTTP 頭
? ? ? ? ? ? add_header 'Access-Control-Allow-Credentials' 'true'; #添加額外的 HTTP 頭 ? ? ?
? ? ? ? ?}
? ? ? ? }
? ? }重啟
nginx -s reload
測試
推流
1.ffmpeg -re -i C:\Users\EDY\Desktop\1.mp4 -vcodec libx264 -acodec aac -f flv rtmp://122.112.245.213:54321/myapp/video_test
ffmpeg -re -i \
本地視頻路徑 \
-vcodec libx264 -acodec aac -f flv \
rtmp://服務器ip:端口/rtmp的路由匹配/自定義2. ffmpeg -re -i "video" -c:v copy -c:a aac -b:a 192k -strict -2 -f flv "rtmp"
視頻加水印,水印位置默認在右上角
3. ffmpeg -re -i "video" -i "image" -filter_complex overlay=W-w-5:5 -c:v libx264 -c:a aac -b:a 192k -strict -2 -f flv "rtmp"
拉流
http://122.112.245.213/live?port=54321&app=myapp&stream=video_test
live為拉流地址路由匹配,
port等于推流的端口號
app等于推流的路由
stream等于推流后自定義的文件名
到此這篇關于nginx 搭建http-flv(rtmp)流媒體的方法步驟的文章就介紹到這了,更多相關nginx 搭建http-flv(rtmp)流媒體內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
- nginx-rtmp-module模塊實現(xiàn)視頻點播的示例代碼
- Nginx安裝nginx-rtmp-module模塊的實現(xiàn)
- 通俗易懂講解nginx-rtmp-module
- nginx-rtmp-module構(gòu)建流媒體直播服務器實戰(zhàn)指南
- nginx臨時搭建rtmp服務器的方法實現(xiàn)
- Nginx搭建RTMP流媒體服務器的實現(xiàn)
- nginx?rtmp模塊編譯?arm版本的問題
- 使用Nginx搭載rtmp直播服務器的方法
- Nginx搭建rtmp直播服務器實現(xiàn)代碼
- Nginx-rtmp實現(xiàn)直播媒體實時流效果
- Centos基于Nginx搭建RTMP服務器的實現(xiàn)
相關文章
Prometheus 和 Grafana 通過nginx-exporter監(jiān)控nginx的
nginx-exporter 是 Prometheus 用來從 Nginx 收集指標的組件,這篇文章給大家介紹Prometheus 和 Grafana 通過nginx-exporter監(jiān)控nginx的詳細步驟,感興趣的朋友跟隨小編一起看看吧2024-08-08
centos系統(tǒng)下LNMP環(huán)境一鍵安裝
centos下的LNMP環(huán)境一鍵安裝實現(xiàn)方法,需要的朋友可以參考下。2010-06-06
Nginx三種不同類型的虛擬主機的配置(基于域名、IP 和端口)
本文主要介紹了Nginx多種虛擬主機配置方式,能夠根據(jù)域名、IP 或端口區(qū)分不同的站點,本文就來介紹一下,感興趣的可以了解一下2025-04-04
讓VIM支持Nginx .conf文件語法高亮顯示功能的方法
這篇文章主要給大家介紹了關于讓VIM支持Nginx .conf文件語法高亮顯示功能的方法,文中分別介紹了手動修改和自動化腳本兩種方法的實現(xiàn),都給出了詳細的示例代碼,需要的朋友可以參考借鑒,下面來一起看看吧。2017-07-07

