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 ...
随机推荐
- 转:IT巨头纷纷“卡位” 智能语音成人机交互入口必争之地
http://www.cs.com.cn/xwzx/hwxx/201707/t20170712_5368595.html 随着物联网的迅速发展,作为重要接口的智能语音技术已成为国内外IT巨头的必争之地 ...
- PredictionIO+Universal Recommender快速开发部署推荐引擎的问题总结(2)
1, 对Universal Recommender进行pio build成功,但是却提示No engine found Building and delpoying model [INFO] [Eng ...
- vue2 vue-rout
vue 2.0的路由比起1.0简单了许多,分为以下几个步骤: 1.创建路由块和视图块: to里面是要切换的路径名称 <div id="app"> <div> ...
- 聚簇(或者叫做聚集,cluster)索引和非聚簇索引
字典的拼音目录就是聚簇(cluster)索引,笔画目录就是非聚簇索引.这样查询“G到M的汉字”就非常快,而查询“6划到8划的字”则慢. 聚簇索引是一种特殊索引,它使数据按照索引的排序顺序存放表中.聚簇 ...
- win10使用u盘装回win7
背景:一朋友要我帮忙把系统从win10装回到win7,因为做IT的嘛,想想也难不倒我,况且以前也经常重装系统,硬盘里就有win7的系统,于是很爽快的答应了.电脑拿过来一试才知道原来有这么多坑,原来的系 ...
- Nexus私服忘记用户名密码解决4步走
1 停止nexus服务 [root@node001 bin]# /usr/local/nexus/nexus-2.14.5-02/bin/nexus stop******************** ...
- Java学习笔记19---内部类之简介成员内部类、局部内部类及匿名内部类
内部类,顾名思义,即定义在某个类内部的类,称包含该内部类的类为外部类. 从定义的位置来说,分为成员内部类和局部内部类:从类的特征来说,分为匿名内部类和静态内部类. 今天先简要介绍一下前三种内部类的定义 ...
- 4、ABPZero系列教程之拼多多卖家工具 集成短信发送模块
ABPZero并没有手机短信发送功能,现在我们来集成一个,为后面注册.登录作铺垫. 阿里云短信服务 首先需要在阿里云开通短信服务,连接地址 开通后,在签名管理中添加一个签名 在模板管理中添加一个模板, ...
- 阿里云服务器Tomcat无法从外部访问
一.环境 阿里云 Ubuntu 12.04.5 LTS tomcat和java都是阿里云默认的7的版本,如下图 二.问题 部署后./startup.sh启动tomcat 之后外部访问http://ip ...
- [原创]在Centos7.2上源码安装PHP、Nginx、Zentao禅道
版本 操作系统:CentOS Linux release 7.2.1511 (Core) PHP:5.6.33 Nginx:1.12.2 MySQL:5.6.38(192.168.1.103的Wind ...