您的位置:首页 > 运维架构 > Nginx

通过Nginx搭建flv流媒体服务器。 推荐

2011-05-04 08:47 525 查看



Nginx中的Flv Stream模块能实现flv流媒体的功能,而且支持flv视频进度条拖拽,以下搭建过程使用的Debian 5.0.7。
1、使用如下命令安装编译Nginx所需软件包。
srv75:~# apt-get -y install zlibc libpcre++-dev bzip2 autoconf automake g++ gcc make libssl-dev
2、使用如下命令下载并编译安装Nginx。
srv75:~# useradd nginx -s /usr/sbin/nologin
srv75:~# cd /usr/src
srv75:src# wget http://nginx.org/download/nginx-1.0.0.tar.gz srv75:src# tar -xvzf nginx-1.0.0.tar.gz
srv75:src# cd nginx-1.0.0
srv75:nginx-1.0.0# ./configure --with-http_ssl_module --with-pcre=/usr/local/pcre/ \
--with-zlib=/usr/local/zlib/ --user=nginx --group=nginx \
--prefix=/usr/local/nginx --with-http_flv_module
srv75:nginx-1.0.0# make && make install
3、使用如下命令安装yamdi。yadmi的作用是为flv文件添加关键帧,才能实现拖动播放。
srv75:~# apt-get -y install yamdi
4、修改/usr/local/nginx/conf/nginx.conf文件如下内容。
user nginx nginx;
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.159.75;
root /usr/local/nginx/html/flv/;
index index.html;
charset utf-8;

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

location ~ \.flv {
flv;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

}
5、启动Nginx后配置完成后即可,将flv的文件通过如下命令添加关键帧后,放到/usr/local/nginx/html/flv/目录后,只将一个支持拖拽播放的flash播放器(比如JW Player)放到/usr/local/nginx/html/flv/目录就可以播放http://192.168.159.75/output.flv文件了。
srv75:flv# yamdi -i input.flv -o output.flv
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 休闲 flv Nginx onlyzq