lnmp配置超精简免费flv流媒体服务器笔记
一测试是否已经支持/usr/local/nginx/sbin/nginx -V
如显示有–with-http_flv_module则表示已经支持
否则
cd lnmp*
cd nginx*
./configure --with-http_flv_module
然后make,但不要make install
二编译完,在objs目录下有一个nginx执行文件,就是它了。
备份下原来老的nginx文件
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
在把新objs下的nginx cp到sbin下,执行:cp objs/nginx /usr/local/nginx/sbin/nginx 。
执行 /usr/local/nginx/sbin/nginx -t 测试下,显示没有问题。
再执行:make upgrade
执行:/usr/local/nginx/sbin/nginx -V 将会出现nginx的版本及编译的参数。
三
cd /usr/local/nginx/conf/vhost
打开相应的配置文件
server
{
listen 80;
server_name192.168.1.5;
root /home/;
charset utf-8;
limit_rate_after 10m;
limit_rate 512k;
location ~ \.flv
{
flv;
}
}
四
tar xzvf yamdi-1.4.tar.gz
cd yamdi-1.4
make && make install
给test1.flv文件 添加关键帧,输出为test.flv文件
yamdi -i test1.flv -o test.flv
五
http://域名/player.swf?type=http&file=test.flv
#player.swf是我的JW Player播放器
#http是表示居于http分发方式
#test1.flv是我的flv视频文件
如正常会出现一个播放界面说明成功:点击播放箭头。
六
JW Player播放器yamdi等打包下载地址
http://www.ctdisk.com/file/6031720 以下内容为转载
nginx搭建mp4、flv流媒体服务器
一、FLV视频发布方式简介 FLV视频有两总发布方式 1、
HTTP方式 这种方式要下载FLV视频文件到本地播放,一旦FLV视频文件下载完成,就不会消耗服务器的资源和带宽,但是拖动功能没有RTMP/RTMP流媒体方式强大,很多视频网站都是用HTTP方式实现的,如:YouTube,土豆,酷6等 2、
RTMP/RTMP流媒体方式 这种方式不用下载FLV视频文件到本地,可以实时的播放flv文件,可以任意拖拽播放进度条,但是比较消耗服务器的资源, 二、使用nginx来搭建flv流媒体服务器 1、使用nginx来搭建flv流媒体服务器简介 nginx中的Flv Stream模块能实现flv流媒体的功能,而且支持flv视频进度条拖拽,另外nignx还可以作为方向代理服务器代理后端基于Flash Media Server或者Red5的RTMP/RTMP流媒体服务器
2、下面我们就来搭建一个完整的nginx流媒体服务器 首先安装gcc yum -y install
gcc
gcc-c++
openssl-devel 1)、Nginx服务器的安装
#安装zlib tar xzvf zlib-1.2.3.tar.gz cd zlib/1.2.3 ./configure make && make install cd ../.. #安装pcre tar zxvf pcre-7.9.tar.gz cd pcre-7.9 ./configure --prefix=/usr/local/pcre make && make install 添加mp4支持模块 tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz #安装nginx groupadd www useradd -g www www
tar xzvf nginx-0.8.34.tar.gz cd nginx-0.8.34 ./configure--add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_ssl_module--with-pcre=/root/pcre-7.9 --with-zlib=/root/zlib/1.2.3 --user=www--group=www --prefix=/usr/local/nginx --with-http_flv_module--with-http_stub_status_module make && make install 2)、安装yamdi yadmi的作用是为flv文件添加关键帧,才能实现拖动播放 #下载yadmi #安装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添加以下内容(根据自身情况修改)
其中以下语句解释如下# cat /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/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.40.25;
root
/usr/local/nginx/html/flv_file/;
limit_rate_after 5m;
###
limit_rate 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;
} } }
其中的部分解释如下:
limit_rate_after 5m;
####在flv视频文件下载了5M以后开始限速
limit_rate 512k;
####速度限制为512K 根据配置文件建立网页的存放的更目录 mkdir -p /usr/local/nginx/html/flv_file/ 设置完成后使用如下命令检测配置,正常会出现如下结果 # /usr/local/nginx/sbin/nginx -t the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful 如无问题,使用如下命令启动 # /usr/local/nginx/sbin/nginx # netstat -nulpt | grep 80 tcp
0
0 0.0.0.0:80
0.0.0.0:*
LISTEN
2945/nginx 使用如下命令检测 修改iptables防火墙打开80端口 在客户端使用浏览器访问,如有下面的信息,则证明成功。
http://blog.chinaunix.net/attachment/201109/26/143839_1317021617YCLH.gif
使用 4)、基本上已经设置完毕,但是此时我们测试的时候还需要一个支持拖拽播放的flash播放器,开源的JW Player就可以实现这样的功能,我将编译的播放器上传上来,供大家下载: 下载链接: 下载播放器后,上传到上面设置的/usr/local/nginx/html/flv_file/目录下,同样找一个测试的test1.flv视频文件也放到该目录下! 给test1.flv文件 添加关键帧,输出为test.flv文件
root@localhost flv_file]# yamdi -i test1.flv -o test.flv
5)、启动nginx后测试: http://192.168.40.25/player.swf?type=http&file=test.flv #我的ip是192.168.40.25 #player.swf是我的JW Player播放器 #http是表示居于http分发方式 #test1.flv是我的flv视频文件 如正常会出现如下界面说明成功:点击播放箭头。
http://blog.chinaunix.net/attachment/201109/26/143839_1317021728f771.gif
http://blog.chinaunix.net/attachment/201109/26/143839_13170218200MmT.gif
看看~~
页:
[1]