ubuntu下使用nginx搭建流媒体服务器,实现视频点播
首先我们看如何实现视频点播,视频点播支持flv文件及H264编码视频,ACC编码音频的mp4文件:
第一步,创建单独的目录(因为软件较多,容易混乱),下载需要的软件:
我们需要下载nginx,pcre,zlib,openssl以及nginx-rtmp-module
mkdir work cd work wget http://nginx.org/download/nginx-1.10.3.tar.gz wget http://zlib.net/zlib-1.2.11.tar.gz wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz wget 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. --with-openssl=../openssl-1.0.2k --add-module=../nginx-rtmp-module-master make sudo make install
第四步,进入 /usr/local/nginx/conf,配置nginx.conf文件,在文件末尾添加如下内容:
rtmp {
server {
listen ; application vod {
play /var/flvs; #指定存放视频文件的路径
} application vod_http {
#myserver.com及服务器地址,如果只是本地播放,填写127.0.0.:端口号 就行,端口好看配置文件中http监听的端口下同
play http://myserver.com/vod;
} application vod_mirror {
play /var/local_mirror http://myserver.com/vod;
}
}
}
示例完整版:
#user nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} rtmp {
server {
listen ; 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 ;
keepalive_timeout ; #gzip on; server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# 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 ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 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/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg
ubuntu下使用nginx搭建流媒体服务器,实现视频点播的更多相关文章
- windows环境下基于nginx搭建rtmp服务器
基于nginx搭建rtmp服务器需要引入rtmp模块,引入之后需重新编译nginx linux环境几个命令行就能实现编译,笔者未尝试,网上有很多教程. windows环境还需要安装一系列的编译环境,例 ...
- nginx搭建流媒体服务器的方法详解
一.FLV视频发布方式简介 FLV视频有两总发布方式 1. HTTP方式 这种方式要下载FLV视频文件到本地播放,一旦FLV视频文件下载完成,就不会消耗服务器的资源和带宽,但是拖动功能没有RTM ...
- 【Nginx】如何使用Nginx搭建流媒体服务器实现直播?看完这篇我会了!!
写在前面 最近几年,直播行业比较火,无论是传统行业的直播,还是购物.游戏.教育,都在涉及直播.作为在互联网行业奋斗了多年的小伙伴,你有没有想过如果使用Nginx搭建一套直播环境,那我们该如何搭建呢?别 ...
- centos 7下nginx搭建流媒体服务器【动态添加模块】
1.安装nginx依赖包 yum install gcc gcc-c++ openssl-devel zlib-devel pcre pcre-devel yamdi 2.下载解压nginx_mod_ ...
- nginx搭建流媒体服务器
1.安装PCRE库 到www.pcre.org 下载pcre-8.37.tar.gz tar -zxvf pcre-8.37.tar.gz cd pcre-8.37 ./configure make ...
- Ubuntu下使用nginx和nginx-rtmp-module搭建流媒体服务器的正确姿势
之前在使用nginx和nginx-rtmp-module搭建流媒体服务器的时候遇到一个很尴尬的问题,就是在把nginx-rtmp-module模块添加到nginx中去的时候,我最开始采取的做法是先卸载 ...
- Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具) 最近因为项目关系,收朋友之托,想制作秀场网站,但是因为之前一直没有涉及到这 ...
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器
CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具) 1.先添加几个RPM下载源 1.1)安装RPMforge的CentOS6源 [roo ...
- centos7+nginx+rtmp+ffmpeg搭建流媒体服务器(保存流目录与http目录不要随意配置,否则有权限问题)
搭建nginx-http-flv-module升级代替rtmp模块,详情:https://github.com/winshining/nginx-http-flv-module/blob/master ...
随机推荐
- Java 集成 速卖通开发.
一.申请成为开发者 申请入口:http://isvhz.aliexpress.com/isv/index.htm 说明文档:http://activities.aliexpress.com/open/ ...
- http性能测试工具wrk源码学习之开篇
1.前言 最近工作需要测试nginx反向代理的性能,于是找了一些http测试工具,例如经典的Apache的ab.siege.wrk.wrk使用多线程事件驱动方式,支持lua脚本扩展.关于wrk介绍可以 ...
- ArcGIS API for JavaScript 4.2学习笔记[12] View的弹窗(Popup)
看本文前最好对第二章(Mapping and Views)中的Map和View类有理解. 视图类有一个属性是Popup类型的popup,查阅API知道这个就是视图的弹窗,每一个View的实例都有一个p ...
- @Data 注解引出的 lombok 小辣椒
今天在看代码的时候, 看到了这个注解, 之前都没有见过, 所以就查了下, 发现还是个不错的注解, 可以让代码更加简洁. 这个注解来自于 lombok,lombok 能够减少大量的模板代码,减少了在使用 ...
- LAMP第一部分-环境搭建
1. 安装mysqlcd /usr/local/src/ wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686- ...
- Unable to make the module: related gradle configuration was not found. Please, re-import the Gradle project and try again
到stack overflow找到的答案,老外还是专业 I also had a similar problem, Go to : View -> Tool Windows -> Grad ...
- RAID常用级别的比较
[转]RAID常用级别的比较 特点 硬盘及容量 性能及安全 典型应用 raid 0 用于平行存储,即条带.其原理是把连续的数据分成几份,然后分散存储到阵列中的各个硬盘上.任何一个磁盘故障,都将导致数据 ...
- web打印总结
一.打印样式 区别显示和打印的样式 使用media="print"控制打印时的样式,如下: 打印时不显示打印按钮,设置页面宽度 <style media="prin ...
- HDFS Architecture
http://hadoop.apache.org/docs/r2.9.0/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html Introduction Ha ...
- while求1+2+3+4+5+6....100的和
#求1到100的和. #声明i初始变量 i = 1 #声明y初始变量 y = 1 #开始循环条件为i不等于100,则执行while代码块 while i != 100: #给i加1 i += 1 #y ...