-
CentOS 7 使用 Nginx 搭建视频点播服务器
2020-02-02 03:47:40完成在 CentOS 7 的系统搭建的视频点播服务能够提供给 VR 设备 RMTP 协议或 HTTP 协议的视频在线观看 环境依赖: gcc 依赖:此次安装 Nginx 的方式因为需要添加模块 nginx-rmtp-moudle,故采用源码编译安装,因此...目标:
完成在 CentOS 7 的系统搭建的视频点播服务能够提供给 VR 设备 RMTP 协议或 HTTP 协议的视频在线观看
环境依赖:
- gcc 依赖:此次安装 Nginx 的方式因为需要添加模块 nginx-rmtp-moudle,故采用源码编译安装,因此需要 gcc 依赖
安装:yum -y install gcc gcc-c++
- PCRE(Perl Compatible Regular Expressions) 是一个 Perl 库,包括 perl 兼容的正则表达式库。Nginx 的 HTTP 模块使用 pcre 来解析正则表达式,所以需要安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。
安装:yum -y install pcre pcre-devel
- zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
安装:yum -y install zlib zlib-devel
- OpenSSL 依赖:nginx 不仅支持 http 协议,还支持 https
安装:yum -y install openssl openssl-devel
Nginx 安装:
- 官网下载直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html
解压 tar 包:tar-zxvf nginx-xxx.tar.gz
- 下载 rtmp 模块, nginx-rtmp-module的官方github地址:https://github.com/arut/nginx-rtmp-modul
解压 rtmp 包:tar zxvf nginx-rtmp-moudle.tar.gz
安装nginx跟rtmp模块
./configure --prefix=/usr/local/nginx --add-module=../nginx-rtmp-module --with-http_ssl_module make & make install
在 nginx.conf 配置中添加:
location ~*\.flv$ { root /usr/local/nginx/vedio; } location ~*\.mp4$ { root /usr/local/nginx/vedio; }
注意:/usr/local/nginx/vedio 是存放视频的位置
#开启RTMP点播服务 application vod { #点播资源 play /usr/local/nginx/vedio; } application vod_http { play http://192.168.108.62:99/vod; }
注意:上述 url 请根据自己实际的服务器地址修改
完整的 nginx.conf 配置文件如下
#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; } 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 99; 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 # ######## 配置 rtmpt 拉流服务 ############## location /hls { types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /hls/; add_header Cache-Control no-cache; } location ~*\.flv$ { root /usr/local/nginx/vedio; } location ~*\.mp4$ { root /usr/local/nginx/vedio; } 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; # } #} } ########### rtmp配置 ################ rtmp { server { # rtmp 端口 listen 1935; chunk_size 4000; #开启RTMP直播服务 application live { #打开直播 live on; #关闭录制 record off; } #开启hls直播服务 application hls { #打开直播 live on; hls on; #切片路径 hls_path /hls; # 切片时间 hls_fragment 5s; } #开启RTMP点播服务 application vod { #点播资源 play /usr/local/nginx/vedio; } application vod_http { play http://192.168.108.62:99/vod; } } }
启动 nginx
#启动nginx: ./nginx #关闭nginx: ./nginx -s stop #重启nginx: ./nginx -s reload
访问方式:
- RTMP + VLC:下载 VLC 视频播放器,在应用的左上角 媒体->打开网络串流->网络 中输入:rtmp://<nginx 服务器的 ip>:<端口>/<需要播放的视频文件>
- HTTP:浏览器直接输入:http://<nginx 服务器的 ip>:<端口>/<需要播放的视频文件>
-
CentOS 7配置Nginx代理服务,搭建视频点播服务器
2020-06-12 17:55:12在 CentOS 7 系统上,基于RMTP 协议或 HTTP 协议,搭建的视频点播服务,能够提供给 VR 设备 ,进行视频在线观看。 环境依赖: 安装gcc 依赖 由于采用安装 Nginx 的方式,所以需要添加模块 nginx-rmtp-moudle,故...前言:
在 CentOS 7 系统上,基于RMTP 协议或 HTTP 协议,搭建的视频点播服务,能够提供给 VR 设备 ,进行视频在线观看。
环境依赖:
安装gcc 依赖
由于采用安装 Nginx 的方式,所以需要添加模块 nginx-rmtp-moudle,故采用源码编译安装,因此需要 安装gcc 依赖
yum -y install gcc gcc-c++
安装PCRE
PCRE(Perl Compatible Regular Expressions) 是一个 Perl 库,包括 perl 兼容的正则表达式库。Nginx 的 HTTP 模块使用 pcre 来解析正则表达式,所以需要安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库,nginx也需要此库。yum -y install pcre pcre-devel
安装zlib 库
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum -y install zlib zlib-devel
安装OpenSSL 依赖
nginx 不仅支持 http 协议,还支持 https,故安装OpenSSL 依赖
yum -y install openssl openssl-devel
Nginx 安装
官网下载直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html
解压 tar 包:
tar-zxvf nginx-xxx.tar.gz
解压 rtmp 包:
下载 rtmp 模块, nginx-rtmp-module的官方github地址:https://github.com/arut/nginx-rtmp-modul
tar zxvf nginx-rtmp-moudle.tar.gz
安装nginx跟rtmp模块:
./configure --prefix=/usr/local/nginx --add-module=../nginx-rtmp-module --with-http_ssl_module make & make install
nginx.conf 配置
location ~*\.flv$ { root /usr/local/nginx/vedio; } location ~*\.mp4$ { root /usr/local/nginx/vedio; } #开启RTMP点播服务 application vod { #点播资源 play /usr/local/nginx/vedio; } application vod_http { play http://172.168.108.62:99/vod; }
注意:
- /usr/local/nginx/vedio 是存放视频的位置
- url 请根据自己实际的服务器地址修改
启动 nginx:
/usr/local/nginx/sbin/nginx systemctl status nginx
访问方式:
RTMP + VLC:
下载 VLC 视频播放器,在应用的左上角 媒体->打开网络串流->网络 中输入:
rtmp://<nginx 服务器的 ip>:<端口>/<需要播放的视频文件>HTTP:
浏览器直接输入:
http://<nginx 服务器的 ip>:<端口>/<需要播放的视频文件> -
Nginx+RTMP 搭建视频点播服务器
2017-10-25 17:44:43配置rtmp{……} rtmp { server { listen 1935; chunk_size 4096; application vod { ...VLS 点播地址:rtmp://192.168.1.152/vod/source.200kbps.768x320.flv配置rtmp{……}
rtmp {
server {
listen 1935;
chunk_size 4096;
application vod {
play /usr/local/nginx/html/liverecord;
}
}
}配置 http {……}
http {
include mime.types;
default_type application/octet-stream;sendfile on;
tcp_nopush on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}}
在/usr/local/nginx/html/liverecord 目录 存放source.200kbps.768x320.flv 文件
VLS 点播地址:rtmp://192.168.1.152/vod/source.200kbps.768x320.flv
-
Windows环境下用jwplayer+Nginx搭建视频点播服务器
2012-08-31 12:57:02该资源文件用于 Windows服务器环境下flv视频播放——对未缓冲进度条实现拖动 该nginx服务器已经做好了相关的配置,支持视频的播放。相关文章说明请参考http://hi.baidu.com/mtb573/item/6a7115558f9b649f8c12ed9e -
Nginx搭建视频点播服务器(仿真专业流媒体软件)
2012-10-11 19:52:07最近研究视频点播服务器的搭建方案,因项目原因笔者只能忍痛割爱舍弃专业的流媒体软件HelixServer、RED5、WMS等专业的流媒体软件当然其中还有不要钱的Darwin。按照坑爹的要求使用web服务器作为视频点播服务器。 ...最近研究视频点播服务器的搭建方案,因项目原因笔者只能忍痛割爱舍弃专业的流媒体软件HelixServer、RED5、WMS等专业的流媒体软件当然其中还有不要钱的Darwin。按照坑爹的要求使用web服务器作为视频点播服务器。
经过前期调研发现选择Nginx也不失为一种理想的替代方案,可是网络上的资料大多不够完整和详尽且没有给出在部署过程中产生的错误相应的解决方法,所以笔者只好自己亲自动手整理和编写了一篇完整版安装手记,以供大家借鉴和参考。
一、部署前的环境准备工作
1)检查当前系统是否已经安装zlib、pcre基础软件包
rpm –qa | grep zlib ##Nginx运行需要的函数库
rpm –qa | grep pcre ##与Perl兼容的正则表达式库模块
rpm –qa | grep ssh ##openssh 支持安全的通信
2)准备安装的软体
A)nginx-1.0.5.tar.gz ##运行主程序
B)nginx_mod_h264_streaming-2.2.7.tar.gz ##MP4支持模块
C)nginx-accesskey-2.0.3.diff.bz2 ##资源防盗链支持模块
##wget http://wiki.nginx.org/images/5/51/Nginx-accesskey-2.0.3.tar.gz
D)yamdi-1.4.tar.gz
##渐进式流支持模块(抓取视频资源关键帧实现播放时的随意拖动效果)
E)准备一个播放器
http://blogimg.chinaunix.net/blog/upfile2/100607142612.rar ##flash播放器控件
F)测试资源准备
二、部署步骤
A)安装yamdi
1、解压下载的文件tar –zxvf yamdi-1.8.tar.gz
2、进入解压后的目录cd yamdi-1.8.
3、编译并安装 make && make install
4、使用该软件为视频添加关键帧信息实现拖动效果
具体使用方法如下yamdi -i input.mp4 -o out.mp4 (拖拽功能必须的一步呀)
B)安装Nginx
1、访问http://nginx.org/download/官网下载最新版本的Nginx程序
wget http://nginx.org/download/nginx-1.3.3.tar.gz
2、访问http://h264.code-shop.com官网下载最新版本的MP4支持模块
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
3、访问http://sourceforge.net官网下载支持流媒体拖动功能模块
wget http://sourceforge.net/projects/yamdi/files/yamdi/1.8/yamdi-1.8.tar.gz/download
./configure --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_ssl_module --with-pcre --with-zlib --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module
4、下载pcre包wget http://autosetup1.googlecode.com/files/pcre-7.9.tar.gz
5、下载zlib包wget http://google-desktop-for-linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz
6、解压文件tar –zxvf pcre-7.9.tar.gz
7、cd pcre-7.9 配置编译环境./configure –prefix=/usr/local/pcre
8、安装程序make && make install
9、安装部署nginx软体
./configure --add-module=/nginx/nginx_mod_h264_streaming-2.2.7 --with-pcre=/nginx/pcre-7.9 --with-zlib=/nginx/zlib/1.2.3 --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-openssl-opt=enable --with-http_mp4_module --add-module=/nginx/nginx-accesskey-2.0.3 --with-cc-opt='-O3
提示以下错误信息:
make -f objs/Makefile
make[1]: Entering directory `/nginx/nginx-1.3.3'
cd /usr/local/pcre/ \
&& if [ -f Makefile ]; then make distclean; fi \
&& CC="gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared
/bin/sh: line 2: ./configure: No such file or directory
make[1]: *** [/usr/local/pcre//Makefile] Error 127
make[1]: Leaving directory `/nginx/nginx-1.3.3'
make: *** [build] Error 2
导致发生该错误的原因是依赖程序路径应指定到源码包而非安装后的程序包。
所以在配置编译环境是应这样写
./configure --add-module=/nginx/nginx_mod_h264_streaming-2.2.7 --with-pcre=/nginx/pcre-7.9 --with-zlib=/nginx/zlib/1.2.3 --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-openssl-opt=enable --with-http_mp4_module --add-module=/nginx/nginx-accesskey-2.0.3 --with-cc-opt='-O3'(正确的指令)
Ok!通过查看返回信息一切正常!
10、继续编译该软体使用make命令,哈哈报错啦!(有error信息打印不见的是一件坏事哦)报错信息如下:
make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1
make: *** [build] Error 2
解决方法:
进入支持MP4格式播放的库/nginx/nginx_mod_h264_streaming-2.2.7/src修改ngx_http_h264_streaming_module.c该文件。修改内容如下所示:
将如下几行注释
/* TODO: Win32 */
if (r->zero_in_uri)
{
return NGX_DECLINED;
}后我们再次make clean && make一下nginx,呵呵这次终于成功了。11、make install 安装完成
12、验证已安装的Nginx服务器是否支持mp4、flv等视频
cd /usr/local/nginx/sbin
nginx –V
configure arguments:
--add-module=/nginx/nginx_mod_h264_streaming-2.2.7 --with-pcre=/nginx/pcre-7.9 --with-zlib=/nginx/zlib/1.2.3 --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-openssl=/nginx/openssl-0.9.3 --with-http_mp4_module --with-cc-opt='-O3'
13、配置Nginx配置文件
cd /usr/local/nginx/conf/
vi nginx.conf ##修改配置文件
user videoapp video; ##管理用户
worker_processes 8; ##后台进程
error_log /usr/local/nginx/logs/error.log;
##nginx错误日志存放路径
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 $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/nginx/logs/access.log;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 801;
server_name localhost;
root /usr/local/nginx/html ;
#charset koi8-r;
limit_rate_after 5m;
limit_rate 512k;
charset utf-8;
access_log /usr/local/nginx/logs/host.access.log main;
location / {
root html;
index index.html index.htm;
# limit_rate_after 5m;
# limit_rate 512k;
}
#error_page 404 /404.html;
location ~ \.flv$ {
flv;
}
location ~ \.mp4$ {
mp4;
}
location ~(favicon.ico) {
log_not_found off;
expires 30d;
break;
}
14、拷贝视频及falsh播放器到video目录下
15、拖动播放测试http://127.0.0.1:801/video/player.swf?type=http&file=2.flv
http://127.0.0.1:801/player.swf?type=http&file=xxy.mp4
三、后续完善的工作
1、为节省带宽防止用户直接下载视频我们需要做如下设置(视频防盗链):
1、到http://wiki.codemongers.com/NginxHttpAccessKeyModule去下载防盗链模块,没办法总有人想下载。还是要做好防盗链工作的。
需要注意的是,下载完防盗链模块之后需要修改下配置文件讲config文件中的“$HTTP_ACCESSKEY_MODULE” 改成“ngx_http_accesskey_module”,不改的话没办法开启防盗链模块。
2、执行编译:./configure --add-module=/nginx/nginx_mod_h264_streaming-2.2.7 --with-pcre=/nginx/pcre-7.9 --with-zlib=/nginx/zlib/1.2.3 --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-openssl-opt=enable --with-http_mp4_module --add-module=/nginx/nginx-accesskey-2.0.3 --with-cc-opt='-O33、make && make install 安装完毕其他配置参数同上13步骤的配置
4、最后开启防盗链功能
location ~ \.mp4$ {
mp4;
limit_conn one 2;
limit_rate 200k;accesskey on;
accesskey_hashmethod md5;
accesskey_arg “key”;
accesskey_signature “movie.weiqp.cn$remote_addr”;
} -
搭建视频点播服务器 nginx/ flv /jw flv player
2014-01-23 12:06:01最近需要独立完成一个视频点播系统,作为当前A系统的一个大模块,一开始没什么头绪,因为之前没有接触过这方面的东西,后来经过不断的查找资料,总算慢慢找到一些线索,至少能提出并实践一个简易版的视频点播服务... -
2003中搭建视频点播服务器1
2010-03-17 11:25:35因而很多娱乐网站都提供Real格式的媒体资源,以让用户进行访问,如在线电影,视频点播等。Real服务就是Real公司的流 媒体服务器软件,其最新版本为Helix Server。它提供了对RM、RMVB、FLASH、RP/RT、MPEG-1、MPEG-4... -
2003中搭建视频点播服务器2
2010-03-17 11:27:19在Helix Server安装完成后,它并不能立即提供视频点播服务。首先必须要为其绑定IP地址,才可以让用户访问到它。另外,由于默认主 目录(即安装目录)为系统分区,还应当将它修改为其他磁盘容量更大的数据分区才行... -
2003中搭建视频点播服务器3
2010-03-17 11:28:49在进行适当的下载缓存后即开始播放,从而实现视频点播的 目的。另外,可以将 RM 格式文件直接放在 Web 服务器中的目录中,这时客户端用户也可以使用 HTTP 文件来访问。但这种方式可能会造成客 户端用户... -
2003中搭建视频点播服务器4
2010-03-17 11:30:18通常情况下,速率越低则压缩率越高,此时视频和音频的效果越差。需要 注意的是,右侧栏中最好只保留一种速率。否则,系统将为每一种速率都压缩一个 RM 格式文件,从而占用过多的磁盘空间。如果要删除一 种... -
win 2003中搭建视频点播服务器
2008-05-09 08:34:00如今网络上最流行的多媒体格式得算是RM格式了,这种格式由于压缩率高以及体积小的特点,所以特别适合于在网络上传播,因而很多娱乐网站都提供Real格式的媒体资源,以让用户进行访问,如在线电影,视频点播等。... -
[转]用jwplayer+Nginx搭建视频点播服务器,解决拖动加载慢的问题
2015-04-12 21:23:00flv视频可以采用两种方式... 两种方式对比如下:Http :生成关键帧后可拖动播放、 下载完成后不再消耗服务器资源Rtmp/rtmpt: 任意拖动播放 、无缓存,每次播放都会消耗服务器资源 这里说一下怎么用nginx 搭建http ... -
Nginx搭建视频点播和视频直播服务器
2019-05-02 18:47:53Nginx搭建视频点播和视频直播服务器 一·、环境: Centos 7,(推荐,Ubuntu不是很好用,经常会有一些莫名其妙的报错) Nginx1.10.1 二、系统环境搭建 首先,我是不建议自己一个个去安装这些软件的,耗时耗力,而且... -
使用nginx搭建媒体点播服务器
2017-08-07 18:15:00最新由于兴趣,对ubuntu和安卓上的视频点播直播等应用比较感兴趣,所以在vmware的虚拟机里面搭建了一个视频点播网站,参考了fengzhanhai的文章Nginx搭建视频点播服务器(仿真专业流媒体软件)。 1,环境的准备 1)... -
Nginx搭建flv视频点播服务器
2015-11-23 16:49:00Nginx搭建flv视频点播服务器 前一段时间使用Nginx搭建的多媒体服务器只能在缓冲过的时间区域内拖放, 而不能拖放到未缓冲的地方. 这就带来了一个问题: 如果视频限速的速率很小, 那么客户端观看视频时肯定不流畅, ... -
如何搭建个人视频点播服务器
2016-04-07 15:22:54如何搭建个人视频点播服务器 服务器 专业回答 宣城_840 2012-11-06 16:11 很多单位和企业都组建了自己的局域网,在局域网中,通过架设文件共享服务器或BT服务器,能方便地和其他人共享精彩的电影。如果有... -
利用nginx搭建RTMP视频点播、直播、HLS服务器
2016-03-09 23:48:32开发环境 Ubuntu 14.04 server ...nginx的服务器的搭建安装nginx的依赖库sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev sudo apt-get install openssl libssl-dev配置并编译nginx 使用nginx的默
-
VDA_6.3-2016英文版.pdf
-
安装Pangolin的步骤及问题解决
-
LVS + Keepalived 实现 MySQL 负载均衡与高可用
-
各种301大全windows和nginx
-
基于电商业务的全链路数据中台落地方案(全渠道、全环节、全流程)
-
Android USB Driver Manager 9.16.1.28 Setup.exe
-
竞品分析工作制度及指导办法v1.1.doc
-
C/C++反汇编解密
-
面试总结
-
基于分脉冲放大法的皮秒脉冲放大器的数值研究
-
MySQL 函数、用户自定义函数
-
MySQL 备份与恢复详解(高低版本 迁移;不同字符集 相互转换;表
-
被动锁模光纤激光器中增益支配孤子的腔致峰值功率钳位效应(英文)
-
VDA6.3:2016红皮书中文版检查表部分(P2-P7)-updated.pdf
-
每日算法-多数元素
-
口语交际:我的暑假生活.docx
-
口语交际:身边的“小事”.docx
-
字计数器-源码
-
xxljob源码分析
-
libFuzzer视频教程