日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

實驗?zāi)康?讓Nginx支持flv和mp4格式文件,同時支持Rtmp協(xié)議;同時打開rtmp的hls功能
資料:
HTTP Live Streaming(縮寫是 HLS)是一個由蘋果公司提出的基于HTTP的流媒體 網(wǎng)絡(luò)傳輸協(xié)議。
HLS只請求基本的HTTP報文,與實時傳輸協(xié)議(RTP)不同,HLS可以穿過任何允許HTTP數(shù)據(jù)通過的防火墻或者代理服務(wù)器。它也很容易使用內(nèi)容分發(fā)網(wǎng)絡(luò)來傳輸媒體流。
使用ffmpeg來完成對flv、mp4、mp3等格式的轉(zhuǎn)化(點播實驗暫時不測試)

一、流媒體播放方式
1、 HTTP方式
這種方式要下載FLV視頻文件到本地播放,一旦FLV視頻文件下載完成,就不會消耗服務(wù)器的資源和帶寬,但是拖動功能沒有RTMP/RTMP流媒體方式強大,很多視頻網(wǎng)站都是用HTTP方式實現(xiàn)的,如:YouTube,土豆,酷6等
2、 RTMP/RTMP流媒體方式
這種方式不用下載FLV視頻文件到本地,可以實時的播放flv文件,可以任意拖拽播放進度條,但是比較消耗服務(wù)器的資源。
二、使用nginx來搭建flv流媒體服務(wù)器
1.安裝git

yum install git


2.安裝依賴包

yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64


3、安裝ffmpeg及其依賴包(我的依賴包安裝在/usr/local/src下,不過安裝位置可以根據(jù)個人習(xí)慣而定)
以下安裝包能用yum安裝的,盡量用yum來安裝,沒有的再wget來獲得。

#wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
#tar xzvf yasm-1.2.0.tar.gz
#cd yasm-1.2.0
#./configure
#make
#make install
#cd ..

#git clone git://git.videolan.org/x264
#cd x264
#./configure --enable-shared 
#make
#make install
#cd ..

#wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
#tar xzvf lame-3.99.5.tar.gz
#cd lame-3.99.5
#./configure --enable-nasm
#make
#make install
#cd ..

#yum install libogg
注:libogg根據(jù)網(wǎng)上各版本教程都是用的.tar.gz包來安裝,不過安裝后再安裝libvorbis,libvpx等會發(fā)現(xiàn)找不到libogg安裝位置,導(dǎo)致安裝失敗。

#wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
#tar xzvf libvorbis-1.3.3.tar.gz
#cd libvorbis-1.3.3
#./configure
#make
#make install
#cd ..

#git clone http://git.chromium.org/webm/libvpx.git
#cd libvpx
#./configure --enable-shared
#make
#make install
#cd ..

#wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
#tar zxvf faad2-2.7.tar.gz
#cd faad2-2.7
#./configure
#make
#make install
#cd ..

#wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
#tar zxvf faac-1.28.tar.gz
#cd faac-1.28
#./configure
#make
#make install
#cd ..

#wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
#tar zxvf xvidcore-1.3.2.tar.gz
#cd xvidcore/build/generic
#./configure
#make
#make install
#cd ..

#git clone git://source.ffmpeg.org/ffmpeg
#cd ffmpeg
#./configure --prefix=/opt/ffmpeg/ --enable-version3 --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-shared --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads
#make && make install
#cd ..

修改/etc/ld.so.conf如下:
include ld.so.conf.d/*.conf
/lib
/lib64
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/ffmpeg/lib

三、安裝nginx模塊

#wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
#tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz

#git clone git://github.com/arut/nginx-rtmp-module.git

#yum install pcre
nginx沒有找到地址,只能手動下載,然后上傳了。
#tar zxvf nginx-1.2.6.tar.gz
#cd nginx-1.2.6
#./configure --prefix=/usr/local/nginx --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_mp4_module --add-module=../nginx-rtmp-module --add-module=../nginx-rtmp-module/hls --with-cc-opt=-I/opt/ffmpeg/include --with-ld-opt='-L/opt/ffmpeg/lib -Wl,-rpath=/opt/ffmpeg/lib'
#make && make install

安裝yamdi
yadmi的作用是為flv文件添加關(guān)鍵幀,才能實現(xiàn)拖動播放
#下載yadmi
wget http://sourceforge.net/projects/yamdi/files/yamdi/1.4/yamdi-1.4.tar.gz/download
#安裝yadmi
tar xzvf yamdi-1.4.tar.gz
cd yamdi-1.4
make && make install
使用方法:yamdi -i input.flv -o out.flv
給input.flv文件 添加關(guān)鍵幀,輸出為out.flv文件

四、修改nginx主配置文件

vi /usr/local/nginx/conf/nginx.conf

user www www;

worker_processes 30;

error_log /usr/local/nginx/logs/error.log crit;

pid /usr/local/nginx/logs/nginx.pid;



events {

use epoll;

worker_connections 65535;

}

http {

include mime.types;

default_type Application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] '

'"$request" $status $bytes_sent '

'"$http_referer" "$http_user_agent" '

'"$gzip_ratio"';

keepalive_timeout 60;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;



large_client_header_buffers 4 32k;



access_log off;

gzip on;

gzip_min_length 1100;

gzip_buffers 4 8k;

gzip_types text/plain;



output_buffers 1 32k;

postpone_output 1460;



client_header_timeout 3m;

client_body_timeout 3m;

send_timeout 3m;



sendfile on;

tcp_nopush on;

tcp_nodelay on;


server {

listen 80;
server_name 192.168.1.105;
root /usr/local/nginx/html/;
limit_rate_after 5m; ####在flv視頻文件下載了5M以后開始限速
limit_rate 512k; ####速度限制為512K
index index.html;

charset utf-8;

location ~ .flv {

flv;

}

location ~ .mp4$ {
mp4;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}
}

}

五、啟動nginx

啟動前檢測nginx.conf文件配置
/usr/local/nginx/sbin/nginx -t -c /usr/nginx/conf/nginx.conf
或者
/usr/nginx/sbin/nginx -t
如果出錯根據(jù)報錯行數(shù)進行改正。
如果報錯:[error]: invalid PID number "" in "/var/run/nginx.pid"
usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf


nginx啟動
/usr/local/nginx/sbin/nginx -s reload

測試
http://192.168.1.105/player.swf?type=http&file=test1.flv
(其中player.swf為播放器,test1.flv為視頻文件)
播放器要和視頻文件放在一起。
視頻文件位置根據(jù)nginx.conf中配置位置對應(yīng)。

分享到:
標(biāo)簽:流媒體 服務(wù)器
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運動步數(shù)有氧達(dá)人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定