国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Ubuntu > 正文

ubuntu下使用nginx搭建流媒體服務器,實現視頻點播

2024-06-28 16:00:01
字體:
來源:轉載
供稿:網友

為了實現視頻點播和直播,整了一天,看了N多博客,終于有了不小進展,在這里分享給大家。 什么是視頻點播?可能你對這個名詞不熟悉,但是愛奇藝,騰訊視頻等這些視頻播放軟件想必你肯定知道。沒錯,視頻點播就是在線觀看某個視頻。額,視頻直播?這個就不解釋了吧,美女直播,游戲直播等等,哈哈。

首先我們看如何實現視頻點播,視頻點播支持flv文件及H264編碼視頻,ACC編碼音頻的mp4文件: 第一步,創建單獨的目錄(因為軟件較多,容易混亂),下載需要的軟件: 我們需要下載nginx,pcre,zlib,openssl以及nginx-rtmp-module

mkdir workcd workwget http://nginx.org/download/nginx-1.10.3.tar.gzwget http://zlib.net/zlib-1.2.11.tar.gzwget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gzwget https://www.openssl.org/source/openssl-1.0.2k.tar.gzwget https://github.com/arut/nginx-rtmp-module/archive/master.zip

第二步,分別解壓這四個文件:

tar -zxvf 文件名

第三步,編譯安裝nginx:

./configure --PRefix=/usr/local/nginx --with-debug --with-pcre=../pcre-8.40 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2k --add-module=../nginx-rtmp-module-mastermakesudo make install

第四步,進入 /usr/local/nginx/conf,配置nginx.conf文件,在文件末尾添加如下內容:

rtmp { server { listen 1935; application vod { play /var/flvs; #指定存放視頻文件的路徑 } application vod_http { #myserver.com及服務器地址,如果只是本地播放,填寫127.0.0.1:端口號 就行,端口好看配置文件中http監聽的端口下同 play http://myserver.com/vod; } application vod_mirror { play /var/local_mirror http://myserver.com/vod; } }}

示例完整版:

#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;}rtmp { server { listen 1935; application vod { play /video_test; } application vod_http { play http://192.168.1.102:8080/vod; } application vod_mirror { # try local location first, then access remote location play /var/local_mirror http://192.168.1.102:8080/vod; } }}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 8080; 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; #} } # 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; # } #}}

然后,進入與conf文件夾同級的sbin目錄下,運行:

sudo ./nginx

至此,服務器搭建完成,可以實現視頻點播了。 視頻點播測試: 播放位于 /video_test 下的file.flv視頻文件:

ffplay rtmp://localhost/vod//file.flv

可以使用VLC這個播放器或者ffplay(需要安裝ffmpeg),VLC自行百度安裝即可。 ffmpeg安裝:

sudo apt-add-repository ppa:jon-severinsson/ffmpegsudo apt-get updatesudo apt-get install ffmpeg
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 梧州市| 竹山县| 芜湖县| 南康市| 铁岭市| 屏南县| 东至县| 义乌市| 莫力| 蓬安县| 介休市| 林西县| 阿克苏市| 方正县| 中宁县| 政和县| 乐昌市| 久治县| 乃东县| 宜川县| 志丹县| 宁河县| 麦盖提县| 南城县| 铁岭县| 双牌县| 新和县| 白玉县| 新宁县| 板桥市| 原阳县| 陵川县| 电白县| 天全县| 门源| 山阳县| 石台县| 玉屏| 丹东市| 三河市| 乌苏市|