nginx的安装参考:http://lpyyn.iteye.com/blog/2224379
nginx对MP4的支持模块使用Mod-H264-Streaming-Nginx-Version2 ,可以在其官网下载:http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Nginx-Version2
安装步骤:
- 下载http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz , 解压。
- 注释掉解压目录下src/ngx_http_streaming_module.c文件的158~161行的代码,如下图。
- 跳转到nginx解压目录,配置安装MP4模块支持。
./configure --prefix=/server/nginx --add-module=../nginx_mod_h264_streaming-2.2.7 make make install
./configure user=www --group=www --prefix=/usr/local/nginx --with-http_spdy_module --with-http_stub_status_module --with-http_ssl_module --with-http_mp4_module --with-http_flv_module --with-pcre注:mp4_limit_rate 和 mp4_limit_rate_after只有在商业版本的nginx中才有,参考:https://www.nginx.com/products/streaming-media-delivery/ ,可以使用limit_rate 和 limit_rate_after做下载带宽的限制。如下命令:在下载10m之后,限制传输带宽为150k。
location ~* \.mp4$ { root /vedio ; mp4 ; mp4_buffer_size 1m ; mp4_max_buffer_size 10m ; limit_rate 150k ; limit_rate_after 10m ; }