Nginx整合mp4,flv模块

注:

nginx 1.1.3之后已经默认支持mp4,flv模块,无须第三方模块支持。

 

操作步骤:

1:解压,编译nginx,编译添加mp4,flv模块:

1
2
3
4
5
# tar -zxvf nginx-1.3.14.tar.gz
# cd nginx-1.3.14
# ./configure 
# ./configure --prefix=/usr/local/nginx --user=nobody --group=nobody --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_sub_module --with-http_stub_status_module --with-http_perl_module --with-http_mp4_module --with-http_flv_module
# make&& make install


2:配置nginx.conf文件:(server选项配置)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# limit_conn_zone $binary_remote_addr zone=perip:10m;
server {
    listen 80 ;
    server_name 117.27.135.82;
    root  /usr/local/nginx/html/mp4_file/;    ----------根路径
    limit_rate 256k;
  
    location ~ \.flv$                      ---------匹配flv文件
     {
         flv;
     }
  
    location ~ \.mp4$                    ----------匹配mp4文件
     {
     mp4;
#    mp4_buffer_size     1m;        
#    mp4_max_buffer_size   5m;
     limit_rate_after 5m;                ---------下载5m后再限速
     limit_rate 100k;                    ----------限速100k
#    limit_conn perip 1;
     }


3:下载JWplayer,实现视频可拖拽功能。解压,并把player.swf文件放到视频文件目录下。

 

 

播放测试:

 在根目录下放入mp4文件VGA.mp4。在浏览器上播放视频。

 地址:http://xx.xx.xx.xx/player.swf?type=http&file=VGA.mp4  (player.swf为播放器,VGA.mp4为要播放的视频文件)

 能正常播放,说明配置成功,如下图:

Nginx整合mp4,flv模块










本文转自 icenycmh 51CTO博客,原文链接:http://blog.51cto.com/icenycmh/1795934,如需转载请自行联系原作者