I. Introduction of FLV Video Publishing method
FLV Video has two general publishing methods
1. HTTP mode
This way to download the FLV video file to local playback, once the FLV video file download is complete, will not consume the server resources and bandwidth, but the drag function is not rtmp/rtmp streaming media powerful, many video sites are implemented in HTTP, such as: YouTube, potatoes, cool 6, etc.
2, rtmp/rtmp streaming media mode
This method does not download the FLV video file to the local, can play the FLV file in real-time, can drag and drop the progress bar, but compared to consume the resources of the server,
Second, use Nginx to build FLV streaming Media server
1, using Nginx to build FLV Streaming Media Server Introduction
The FLV stream module in Nginx can realize the function of FLV streaming media, and support the FLV video progress bar drag and drop, in addition, NIGNX can also be used as direction Proxy server Proxy backend based on flash media server or RED5 rtmp/rtmp streaming media server
2, below we will build a complete nginx streaming media server
1), installation of Nginx server
#安装zlib
Tar xzvf zlib-1.2.3.tar.gz
CD zlib-1.2.3
./configure
Make && make install
#安装pcre
Tar zxvf pcre-7.9.tar.gz
CD pcre-7.9
./configure--prefix=/usr/local/pcre
Make && make install
#添加mp4支持模块
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
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/zhang/nginx/pcre-7.9--with-zlib=/root/ zhang/nginx/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), install Yamdi
The role of YADMI is to add keyframes to the FLV file to enable drag playback
#下载yadmi
wget http://sourceforge.net/projects/yamdi/files/yamdi/1.4/yamdi-1.4.tar.gz/download
#安装yadmi
Tar xzvf yamdi-1.4.tar.gz
CD yamdi-1.4
Make && make install
How to use: Yamdi-i input.flv-o out.flv
Add keyframes to the input.flv file, output as out.flv file
3), configure Nginx
vi/usr/local/nginx/conf/nginx.conf Add the following (modified according to your own situation):
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 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
}
4), basically has been set up, but at this time we also need a test to support drag-and-drop playback of the Flash Player, open-source JW Player can implement such a function, I will compile the player upload, for everyone to download:
Download Link: Http://blogimg.chinaunix.net/blog/upfile2/100607142612.rar
After downloading the player, upload the FLV video files to the directory under the/usr/local/nginx/html/flv_file/directory set above.
5), after the start of Nginx test:
http://192.168.1.105/player.swf?type=http&file=test1.flv
Description: #我的ip是192.168.1.105
#player. SWF is my JW player player
#http是表示居于http分发方式
#test1. flv is my FLV video file
How to build a streaming media server with Nginx