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

2015年(5)

2014年(17)

分类: 系统运维

2014-08-05 20:23:59

  nginx流媒体服务

1、使用nginx来搭建flv流媒体服务器简介

nginx中的Flv Stream模块能实现flv流媒体的功能,而且支持flv视频进度条拖拽,另外nignx还可以作为方向代理服务器代理后端基于Flash Media Server或者Red5RTMP/RTMP流媒体服务器

    2、  下面我们就来搭建一个完整的nginx流媒体服务器

1)、Nginx服务器的安装

           [root@localhost ~]#yum install –y make zlib-devel openssl-devel pcre-devel
           [root@localhost ~]# useradd -M -s /sbin/nologin nginx
           #添加mp4支持模块

             wget

             tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz
             此处应该修改:
             [root@centos1 ~]# vim nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c
             删除:
             if (r->zero_in_uri)
             {
              return NGX_DECLINED;
              }
              [root@centos1 ~]# vim nginx_mod_h264_streaming-2.2.7/Makefile
             NGINX=$(HOME)/nginx-1.5.12/                    NGINX的实际路径
           #
安装nginx
            [root@centos1 ~]# tar zxf nginx-1.5.12.tar.gz
            [root@centos1 nginx-1.5.12]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/root                                     /nginx_mod_h264_streaming-2.2.7 --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module        
            [root@centos1 nginx-1.5.12]# make && make install  
              
            2) #
下载yadmi

                   wget

                   #安装yadmi

           tar xzvf yamdi-1.4.tar.gz

                   cd yamdi-1.4

           make && make install

      使用方法:yamdi -i input.flv -o out.flv

      给input.flv文件 添加关键帧,输出为out.flv文件


           3)  配置nginx

               vi /usr/local/nginx/conf/nginx.conf 添加以下内容(根据自身情况修改):

user  www www;

worker_processes 30;

error_log  /usr/local/nginx/logs/error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

 

events {

        use epoll;

        worker_connections      65535;

        }

http {

        include       mime.types;

        default_type  application/octet-stream;

        log_format main  '$remote_addr - $remote_user [$time_local] '

                                                '"$request" $status $bytes_sent '

                                                '"$http_referer" "$http_user_agent" '

                                                '"$gzip_ratio"';

        keepalive_timeout  60;

        server_names_hash_bucket_size  128;

        client_header_buffer_size    32k;

 

        large_client_header_buffers  4 32k;

 

        access_log off;

        gzip on;

        gzip_min_length  1100;

        gzip_buffers     4 8k;

        gzip_types       text/plain;

 

        output_buffers   1 32k;

        postpone_output  1460;

 

        client_header_timeout  3m;

        client_body_timeout    3m;

        send_timeout           3m;

 

        sendfile                on;

        tcp_nopush              on;

        tcp_nodelay             on;

 

######################################################################

 

server {

        listen       80;

        server_name  192.168.1.105;

        root    /usr/local/nginx/html/flv_file/;

        limit_rate_after 5m;    ####在flv视频文件下载了5M以后开始限速
        limit_rate 512k;         ####速度限制为512K

        index   index.html;

        charset utf-8;

        location ~ \.flv {

            flv;

        }

        location ~ \.mp4$ {
                 mp4;
        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

 

}

}

         
           



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