Deployment of nginx streaming server
Packages
nginx-1.2.3.tar.gz # nginx server
pcre-7.9.tar.gz # regular expression supprot
zlib-1.2.3.tar.gz # liunx下的JFFS文件系统制作工具
yamdi-1.9.tar.gz # The tools can support for draging process bar
openssl # openssl libiary
install upper packages,the process is to uncompress, configure, compile, install.
The following is details about configuration.
install zlib
./configure –prefix=/usr/local/zlib
make && make install
install pcre
./configure –prefix=/usr/local/pcre
make && make install
install openssl
openssl yum install openssl
install nginx_mod_h264_streaming
There is no need to compile it, just uncompress it and modify some file.
tar xzvf nginx_mod_h264_streaming-2.2.7.tar.gz
modify nginx_mod_h264_streaming-2.2.7 source code
annotate ngx_http_streaming_module.c
if (r->zero_in_uri)
{
return NGX_DECLINED;
}
save and exit
install yamdi
tar xzvf yamdi-1.9.tar.gz
cd cd yamdi-1.9
make && make install
install nginx server
groupadd nginx #add user group
useradd -g nginx nginx #add user
./configure
–prefix=/usr/local/nginx \
–add-module=/usr/local/nginx_mod_h264_streaming-2.2.7 \
–with-pcre=/usr/local/pcre-7.9 \
–with-zlib=usr/local/zlib-1.2.3 \
–with-http_stub_status_module \
–with-http_ssl_module \
–with-http_flv_module \
–with-http_mp4_module \
–with-openssl \
–group=www \
–user=www \
make && make install
start nginx service
/usr/local/nginx/sbin # nginx -c /usr/local/nginx/conf/nginx.conf
you can test wheather nginx is working or not by input localhost in url bar.
If “Welcome to nginx!” appeared,this indicate that nginx installation successful.
Now, I need to adjust this streaming server,adding keyframe for flv file, and draging play
can be realized.
I have install yamdi just now,execute following command:
yamdi -i input.flv -o out.flv
add keyframe for input.flv,outputing out.flv
vim /usr/local/nginx/conf/nginx.conf
add supporting featuers for MP4 file.
just add the following code in server field.
location ~ \.flv {
flv;
}
save and exit.
I also need a flash player to support draging play.
download url:http://blogimg.chinaunix.net/blog/upfile2/100607142612.rar
uncompress this tar package and upload the uncompressed file to /usr/local/nginx/html/,
and upload flv file to …/nginx/html/video/.
Edit test page – index.html
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<html><body><h1>视频测试<h1><body><html></br>
<h2>好听的歌曲<h2></br>
<a href=”http://192.168.137.16/video.html” target=_blank”>雨中恋</a></br>
<a href=”http://192.168.137.16/video.html” target=_blank”>渔舟唱晚</a></br>
save and exit
Edit play page video.html
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<h2>付笛声-任静 雨中恋<h2></br>
<embed
type=”application/x-shockwave-flash”
name=”player”
width=”656″
height=”400″
allowscriptaccess=”always”
allowfullscreen=”true”
flashvars=”file=http://192.168.137.16/video/yuzhong1.f4v&image=http://192.168.137.16/video/yuzhong.jpg>
</embed>
save and exit!
Typing http://192.168.137.16 in brower url bar
click “雨中恋”,the page will jump to preview interface
The following figure is in playing process , and can support dragging play.
This article only demo streaming feature, not using front-end technology
because lack of time and energy.