使用nginx搭建媒体点播服务器
使用nginx搭建媒体点播服务器
最新由于兴趣,对ubuntu和安卓上的视频点播直播等应用比较感兴趣,所以在vmware的虚拟机里面搭建了一个视频点播网站,参考了fengzhanhai的文章Nginx搭建视频点播服务器(仿真专业流媒体软件)。
1,环境的准备
1)下载vmware,当然破解版本
2)安装ubuntu 64bit版本,老的电脑可能需要bios里面设置,设置方法百度去。
3)执行sudo apt-get update & sudo apt-get install yum
4)执行sudo apt-get install g++;编译安装pcre的时候需要
2,软件准备
openssl-1.0.1f.zip
JW_Player5.2 ##flash播放器控件
nginx-1.3.3.tar.gz ##服务器主程序
yamdi-1.4.tar.gz ##渐进式流支持模块(抓取视频资源关键帧实现播放时的随意拖动效果)
nginx-accesskey-2.0.3
zlib-1.2.3.tar.gz
nginx_mod_h264_streaming-2.2.7.tar.gz ##MP4支持模块
zlib-1.2.3.tar.gz.1
openssl-1.0.1f.tar.gz
pcre-8.32.tar.gz
3, 编译
1)安装yamdi
A)、解压下载的文件tar –zxvf yamdi-1.8.tar.gz
B)、进入解压后的目录cd yamdi-1.8.
C)、编译并安装 make && make install
D)、使用该软件为视频添加关键帧信息实现拖动效果
具体使用方法如下yamdi -i input.mp4 -o out.mp4 (拖拽功能必须的一步呀)
2) 安装Nginx
A)下载最新版本的Nginx程序(为了安装教程,使用的并不是最新版本)
wget http://nginx.org/download/nginx-1.3.3.tar.gz
3) 访问http://h264.code-shop.com官网下载最新版本的MP4支持模块
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
下载pcre包
wget http://autosetup1.googlecode.com/files/pcre-8.32.tar.gz
4) 下载zlib包
wget http://google-desktop-for-Linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz
5) 加压并编译pcre
tar pcre-8.32.tar.gz
Cd pcre-8.32
./configure –prefix=/usr/local/pcre
Make
Sudo make install
6) 编译nginnx
./configure --add-module=../nginx_mod_h264_streaming-2.2.7 --with-pcre=../pcre-8.32 --with-zlib=../zlib-1.2.3 --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-http_mp4_module --with-cc-opt='-O3' --with-openssl=../openssl-1.0.1f
Make
继续编译该软体使用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,呵呵这次终于成功了。
Sudo make install
注意,所有其他软件包都必须使用zip或者tar命令解开,而且注意configure的时候路径一致。
3)配置nginx服务器
sudo gedit /usr/local/nginx/conf/nginx.conf
修改为
#user nobody;
#user videoapp video; ##管理用户
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
pid /usr/local/nginx/logs/nginx.pid;
events {
use epoll;
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 801;
server_name localhost;
#charset koi8-r;
limit_rate_after 5m;
limit_rate 512k;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location ~ \.flv$ {
flv;
}
location ~ \.mp4$ {
mp4;
}
location ~(favicon.ico) {
log_not_found off;
expires 30d;
break;
}
#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;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
4)启动服务器
Sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
在/usr/local/nginx/html目录下建立video目录,拷贝视频及falsh播放器到video目录下
5)播放
http://127.0.0.1:801/player.swf?type=http&file=xxy.mp4
使用nginx搭建媒体点播服务器
最新由于兴趣,对ubuntu和安卓上的视频点播直播等应用比较感兴趣,所以在vmware的虚拟机里面搭建了一个视频点播网站,参考了fengzhanhai的文章Nginx搭建视频点播服务器(仿真专业流媒体软件)。
1,环境的准备
1)下载vmware,当然破解版本
2)安装ubuntu 64bit版本,老的电脑可能需要bios里面设置,设置方法百度去。
3)执行sudo apt-get update & sudo apt-get install yum
4)执行sudo apt-get install g++;编译安装pcre的时候需要
2,软件准备
openssl-1.0.1f.zip
JW_Player5.2 ##flash播放器控件
nginx-1.3.3.tar.gz ##服务器主程序
yamdi-1.4.tar.gz ##渐进式流支持模块(抓取视频资源关键帧实现播放时的随意拖动效果)
nginx-accesskey-2.0.3
zlib-1.2.3.tar.gz
nginx_mod_h264_streaming-2.2.7.tar.gz ##MP4支持模块
zlib-1.2.3.tar.gz.1
openssl-1.0.1f.tar.gz
pcre-8.32.tar.gz
3, 编译
1)安装yamdi
A)、解压下载的文件tar –zxvf yamdi-1.8.tar.gz
B)、进入解压后的目录cd yamdi-1.8.
C)、编译并安装 make && make install
D)、使用该软件为视频添加关键帧信息实现拖动效果
具体使用方法如下yamdi -i input.mp4 -o out.mp4 (拖拽功能必须的一步呀)
2) 安装Nginx
A)下载最新版本的Nginx程序(为了安装教程,使用的并不是最新版本)
wget http://nginx.org/download/nginx-1.3.3.tar.gz
3) 访问http://h264.code-shop.com官网下载最新版本的MP4支持模块
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
下载pcre包
wget http://autosetup1.googlecode.com/files/pcre-8.32.tar.gz
4) 下载zlib包
wget http://google-desktop-for-linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz
5) 加压并编译pcre
tar pcre-8.32.tar.gz
Cd pcre-8.32
./configure –prefix=/usr/local/pcre
Make
Sudo make install
6) 编译nginnx
./configure --add-module=../nginx_mod_h264_streaming-2.2.7 --with-pcre=../pcre-8.32 --with-zlib=../zlib-1.2.3 --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-http_mp4_module --with-cc-opt='-O3' --with-openssl=../openssl-1.0.1f
Make
继续编译该软体使用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,呵呵这次终于成功了。
Sudo make install
注意,所有其他软件包都必须使用zip或者tar命令解开,而且注意configure的时候路径一致。
3)配置nginx服务器
sudo gedit /usr/local/nginx/conf/nginx.conf
修改为
#user nobody;
#user videoapp video; ##管理用户
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
pid /usr/local/nginx/logs/nginx.pid;
events {
use epoll;
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 801;
server_name localhost;
#charset koi8-r;
limit_rate_after 5m;
limit_rate 512k;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location ~ \.flv$ {
flv;
}
location ~ \.mp4$ {
mp4;
}
location ~(favicon.ico) {
log_not_found off;
expires 30d;
break;
}
#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;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
4)启动服务器
Sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
在/usr/local/nginx/html目录下建立video目录,拷贝视频及falsh播放器到video目录下
5)播放
http://127.0.0.1:801/player.swf?type=http&file=xxy.mp4
使用nginx搭建媒体点播服务器的更多相关文章
- Nginx搭建flv视频点播服务器
Nginx搭建flv视频点播服务器 前一段时间使用Nginx搭建的多媒体服务器只能在缓冲过的时间区域内拖放, 而不能拖放到未缓冲的地方. 这就带来了一个问题: 如果视频限速的速率很小, 那么客户端观看 ...
- 转:Linux下使用Nginx搭建简单图片服务器
最近经常有人问图片上传怎么做,有哪些方案做比较好,也看到过有关于上传图片的做法,但是都不是最好的,今天再这里简单讲一下Nginx实现上传图片以及图片服务器的大致理念. 如果是个人项目或者企业小项目,仅 ...
- Nginx搭建动态静态服务器
Nginx做静态资源服务器优于Tomcat 区分静态资源,动态资源请求 使用域名区分! 如果是动态资源请求 反向代理到 Tomcat 如果 是静态资源请求 直接走本地Nginx 配置: ###静态 ...
- Nginx搭建hls流媒体服务器
第一种方案:ffmpeg+nginx 新的ffmpeg已经支持HLS.(本人也参与了代码供献,给自己做个广告:)) 点播: 生成hls分片: ffmpeg -i <媒体文件> ...
- 使用Nginx搭建本地流媒体服务器
Mac搭建nginx+rtmp服务器 1.打开终端,查看是否已经安装Homebrew,直接输入命令 man brew 如果Mac已经安装了, 会显示一些命令的帮助信息. 此时输入Q退出即可, 直接进入 ...
- nginx搭建mp4流服务器
流媒体服务器 流媒体指以流方式在网络中传送音频.视频和多媒体文件的媒体形式.相对于下载后观看的网络播放形式而言,流媒体的典型特征是把连续的音频和视频信息压缩后放到网络服务器上,用户边下载边观看,而不必 ...
- nginx 搭建上传服务器
nginx webdav 服务器搭建 该模块可以为Http webDAV 增加PUT,DELETE,MKCOL,COPY和MOVE等方法.模块在默认编译的情况下是不被包含的,需要指定编译 ./conf ...
- Nginx 搭建rtmp直播服务器
1.到nginx源码目录新建个rtmp目录 ,进入 git clone https://github.com/arut/nginx-rtmp-module.git 2.重编译nginx 代码如下 ...
- 通过nginx搭建hls流媒体服务器
通过录像文件模拟直播源,通过rtmp协议推送到nginx服务器 nginx 配置文件 增加 rtmp { server { listen 1935; application hls { live on ...
随机推荐
- leetcode-832翻转图像
翻转图像 思路: 先对图像进行水平翻转,然后反转图片(对每个像素进行异或操作) 代码: class Solution: def flipAndInvertImage(self, A: List[Lis ...
- SpringMVC Controller的返回类型
Controller的三种返回类型中 ModelAndView类型 带数据带跳转页面 String 跳转页面不带数据 void 通常是ajax格式请求时使用 1返回ModelAndView contr ...
- HDU 4747 Mex【线段树上二分+扫描线】
[题意概述] 一个区间的Mex为这个区间没有出现过的最小自然数,现在给你一个序列,要求求出所有区间的Mex的和. [题解] 扫描线+线段树. 我们在线段树上维护从当前左端点开始的前缀Mex,显然从左到 ...
- A Small Definition of Big Data
A Small Definition of Big Data The term "big data" seems to be popping up everywhere these ...
- 九度oj 题目1203:IP地址
题目1203:IP地址 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3636 解决:1800 题目描述: 输入一个ip地址串,判断是否合法. 输入: 输入的第一行包括一个整数n(1< ...
- 2017icpc 西安 XOR
XOR Consider an array AAA with n elements . Each of its element is A[i]A[i]A[i] (1≤i≤n)(1 \le i \le ...
- Codeforces 631A Interview【模拟水题】
题意: 模拟模拟~~ 代码: #include<iostream> using namespace std; const int maxn = 1005; int a[maxn], b[m ...
- tomcat8.5.20配置https
一.使用cmd下生成证书: d: cd d:/java/jdk/jdk1.8 keytool -v -genkey -alias tomcat -keyalg RSA -keystore D:\jav ...
- Eclipse 搭建tomcat+动态项目完整版
1. Tomcat搭建 1.新加服务器,右击控制台的server目录->new->server->选择本地tomcat 2.配置tomcat属性(如果更改失败,将tomcat下的项目 ...
- DELPHI、FLASH、AS3、FLEX使用Protobuf(google Protocol Buffers)的具体方法
最近因为工作需要,需要在不同的开发环境中应用Protobuf,特此,我专门研究了一下.为了防止自己忘记这些事情,现在记录在这里!需要的朋友可以借鉴一些,因为这些东西在GOOGLE和百度上搜索起来真的很 ...