nginx之 流式伺服器 直播推拉流等

2021-10-05 01:26:20 字數 2010 閱讀 4656

nginx配置(重點在這)

好了,可以啟動你的nginx了

寫在最後

yum -y install

make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

wget
解壓安裝包

tar zxvf pcre-8.35.tar.gz
進入安裝包目錄,編譯安裝

cd pcre-8.35

./configure

make

&&make

install

注:

pcre

openssl(編譯./config --prefix=/usr/local/openssl 不使用./configure)

# 

unzip unzip master

# 解壓儲存原始碼包即可不需要其它操作,後編譯nginx時需要用到

./configure --prefix=/path/to/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/path/to/pcre-8.35 --add-module=/path/to/nginx-rtmp-module-master
# rtmp配置

rtmp

live on;

hls on;

hls_path /path/to/nginx/html/hls;

# 自己配就行,隨意

hls_fragment 5s;

hls_playlist_length 15s;

# m3u8檔案中指明的ts檔案分段時長

hls_continuous on;

# 連續模式

hls_cleanup on;

#對多餘的切片進行刪除

hls_nested on;

#巢狀模式}}

}# http/server中新增配置

location /hls

#訪問許可權開啟,否則訪問這個位址會報403

autoindex on;

alias /path/to/nginx/html/hls;

expires -1;

add_header cache-control no-cache;

# 跨域配置(到目前為止博主尚未解決flv.js的跨域問題,但是rn、android可以)

add_header 'access-control-allow-origin'

'*';

add_header 'access-control-allow-credentials'

'true'

; add_header 'access-control-allow-methods'

'get, post, options'

; add_header 'access-control-allow-headers'

'dnt,x-customheader,keep-alive,user-agent,x-requested-with,if-modified-since,cache-control,content-type';if

($request_method

='options'

)}

ffmpeg推拉流測試

推流:

ffmpeg -re -i  /path/to/file.mp4   -vcodec copy - acodec copy -f flv rtmp:
拉流:

rtmp:
檢視流資訊:

簡單的Nginx直播伺服器搭建

修改解壓後的資料夾名稱 mv nginx rtmp module master nginx rtmp module 注意 如果提示缺乏庫,可通過sudo apt get install 安裝 make sudo make install 編譯通過後就可以配置nginx了 sudo vi usr lo...

Nginx直播伺服器搭建注意事項

下面是安裝及測試過程可能遇到的問題 站在乙個linux菜鳥角度 1.安裝過程中需要為configure檔案賦予許可權。chmod 需要為伺服器開啟相應埠 3.需要為切片儲存目錄授予許可權,否則不會有切片產生。chmod 777 hls 3.一些可能用到的命令 service nginx restar...

實現方案 Nginx搭建簡單直播伺服器

使用 nginx nginx rtmp module 在ubuntu 中搭建簡單的 rtmp 推流直播伺服器。ubuntu 16.04 rtmp rtmp協議是real time message protocol 實時資訊傳輸協議 的縮寫,它是由adobe公司提出的一種應用層的協議。依賴於flash...