首先我们看如何实现视频点播,视频点播支持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搭建流媒体服务器,实现视频点播的更多相关文章

  1. windows环境下基于nginx搭建rtmp服务器

    基于nginx搭建rtmp服务器需要引入rtmp模块,引入之后需重新编译nginx linux环境几个命令行就能实现编译,笔者未尝试,网上有很多教程. windows环境还需要安装一系列的编译环境,例 ...

  2. nginx搭建流媒体服务器的方法详解

      一.FLV视频发布方式简介 FLV视频有两总发布方式 1.  HTTP方式 这种方式要下载FLV视频文件到本地播放,一旦FLV视频文件下载完成,就不会消耗服务器的资源和带宽,但是拖动功能没有RTM ...

  3. 【Nginx】如何使用Nginx搭建流媒体服务器实现直播?看完这篇我会了!!

    写在前面 最近几年,直播行业比较火,无论是传统行业的直播,还是购物.游戏.教育,都在涉及直播.作为在互联网行业奋斗了多年的小伙伴,你有没有想过如果使用Nginx搭建一套直播环境,那我们该如何搭建呢?别 ...

  4. centos 7下nginx搭建流媒体服务器【动态添加模块】

    1.安装nginx依赖包 yum install gcc gcc-c++ openssl-devel zlib-devel pcre pcre-devel yamdi 2.下载解压nginx_mod_ ...

  5. nginx搭建流媒体服务器

    1.安装PCRE库 到www.pcre.org 下载pcre-8.37.tar.gz tar -zxvf pcre-8.37.tar.gz cd pcre-8.37 ./configure make ...

  6. Ubuntu下使用nginx和nginx-rtmp-module搭建流媒体服务器的正确姿势

    之前在使用nginx和nginx-rtmp-module搭建流媒体服务器的时候遇到一个很尴尬的问题,就是在把nginx-rtmp-module模块添加到nginx中去的时候,我最开始采取的做法是先卸载 ...

  7. Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)

    Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具) 最近因为项目关系,收朋友之托,想制作秀场网站,但是因为之前一直没有涉及到这 ...

  8. CentOS6下基于Nginx搭建mp4/flv流媒体服务器

    CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具) 1.先添加几个RPM下载源 1.1)安装RPMforge的CentOS6源 [roo ...

  9. centos7+nginx+rtmp+ffmpeg搭建流媒体服务器(保存流目录与http目录不要随意配置,否则有权限问题)

    搭建nginx-http-flv-module升级代替rtmp模块,详情:https://github.com/winshining/nginx-http-flv-module/blob/master ...

随机推荐

  1. Nodejs进阶:crypto模块中你需要掌握的安全基础

    本文摘录自<Nodejs学习笔记>,更多章节及更新,请访问 github主页地址. 一. 文章概述 互联网时代,网络上的数据量每天都在以惊人的速度增长.同时,各类网络安全问题层出不穷.在信 ...

  2. sql经典试题

    1.一道SQL语句面试题,关于group by表内容:2005-05-09 胜2005-05-09 胜2005-05-09 负2005-05-09 负2005-05-10 胜2005-05-10 负2 ...

  3. Windows,Mac与Linux哪个更适合开发者?

        以前写的,怕引来口水战,干脆不发.这段时间面试了十来人,用Mac的开发水平明显高于Windows的,挺多感想的,于是改改发了吧.      Windows: 对普通用户而言体验最友好,对开发者 ...

  4. linux下新建svn项目

    1.新建项目svnadmin create /mnt/fbdisk/svn/newproject 2.会在svn下面建立newproject目录total 24drwxr-xr-x 2 root ro ...

  5. vue监听scroll使用报错的解决办法

    错误说明:在切换路由以后,依旧在其他页面触发了scroll有关的函数, 错误原因:在spa项目中,window对象是不变的,所以每次使用后需要销毁. 解决办法:vue的生命周期destroyed中销毁 ...

  6. > library('ggplot2') Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 不存在叫‘colorspace’这个名字的程辑包

    > library('ggplot2')Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : ...

  7. spring boot RESTFul API拦截 以及Filter和interceptor 、Aspect区别

    今天学习一下RESTFul api拦截 大概有三种方式 一.通过Filter这个大家很熟悉了吧,这是java规范的一个过滤器,他会拦截请求.在springboot中一般有两种配置方式. 这种过滤器拦截 ...

  8. 深入剖析MSAA

    本文打算对MSAA(Multisample anti aliasing)做一个深入的讲解,包括基本的原理.以及不同平台上的实现对比(主要是PC与Mobile).为了对MSAA有个更好的理解,所以写下了 ...

  9. Gulp自动化构建工具的简单使用

    相关网站 gulp官方网址:http://gulpjs.com gulp中文网站:http://www.gulpjs.com.cn/ gulp插件地址:http://gulpjs.com/plugin ...

  10. css3实现梯形三角

    近期移动端项目中,图片很多 移动端尽量少图片,以便提升加载速度!这时候css3可以大放光芒比如梯形的背景图 --------------------------------- ------------ ...