Chinaunix首页 | 论坛 | 博客
  • 博客访问: 654376
  • 博文数量: 220
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1961
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-04 21:54
文章分类

全部博文(220)

文章存档

2018年(1)

2015年(140)

2014年(79)

我的朋友

分类: LINUX

2014-12-06 11:38:40

让Nginx支持mp4格式的视频播放,搭建一个mp4流媒体服务器

Saturday, April 16, 2011


在vps上下载了一些mp4格式的视频,点击是直接下载,不能直接在线播放, 所以google了一下有个nginx_mod_h264_streaming的模块。

下载

wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz 

编译安装

./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=/usr/local/src/pcre-8.10 --add-module=/usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/nginx/ --add-module=/usr/local/src/nginx_mod_h264_streaming-2.2.7 make make install 

出错了

.... In file included from /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_h264_streaming_module.c:2: /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’ : /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named zero_in_uri make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1 make[1]: Leaving directory `/usr/local/src/nginx-0.8.54' make: *** [build] Error 2 

解决错误:

因为在新版本的nginx中废弃了zero_in_uri这个flag,稍微修改一下nginx_mod_h264_streaming的源代码

vim /usr/local/src/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c 

把158到161行注释掉

157 /* TODO: Win32 */ 158 //if (r->zero_in_uri) 159 //{ 160 //  return NGX_DECLINED; 161 //} 

然后再make就正常了,make install 完成安装 配置nginx使之支持mp4 在nginx配置文件中加入

location ~ \.mp4$ { mp4; } 

重启nginx

/etc/init.d/nginx restart 

效果来了

image

reference


This entry was tagged ,  and 

阅读(12390) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~