我的步骤如下:
1、 安装依赖包: yum install glibc.i686
#yum –y update
#yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64 gcc-c++
2、安装git工具://新安装的软件都放在新建的softsource文件夹下
#mkdir softsource
#cd softsource
#wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
#tar xzvf git-latest.tar.gz
#cd git-2013-08-28
#autoconf
#./configure
#make && make install
# git --version
git version 1.8.1.GIT
#cd ..
3、安装ffmpeg及其依赖包:
++++++++Yasm+++++++++++
#wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
#tar xzvf yasm-1.2.0.tar.gz
#cd yasm-1.2.0
#./configure
#make
#make install
#cd ..
++++++++x264+++++++++++
#git clone git://git.videolan.org/x264
#cd x264
#./configure --enable-shared
#make
#make install
#cd ..
++++++++LAME+++++++++++
(#wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz)
#wget http://kakola.googlecode.com/files/lame-3.98.4.tar.gz
(安装lame-3.98.4.tar.gz, 以免在第三步的时候出现ERROR:libmp3lame >= 3.98.3 not found错误, 需要提前安装lame.
)
#tar xzvf lame-3.98.4.tar.gz
#cd lame-3.98.4
#./configure --enable-nasm
#make
#make install
#cd ..
++++++++libogg+++++++++++
#wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
#tar xzvf libogg-1.3.0.tar.gz
#cd libogg-1.3.0
#./configure
#make
#make install
#cd ..
++++++++libvorbis+++++++++++
#wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
#tar xzvf libvorbis-1.3.3.tar.gz
#cd libvorbis-1.3.3
#./configure
#make
#make install
#cd ..
++++++++libvpx+++++++++++
#wget http://webm.googlecode.com/files/libvpx-v1.1.0.tar.bz2
#tar -vxjf libvpx-v1.1.0.tar.bz2
#cd libvpx-v1.1.0
#./configure --enable-shared
#make
#make install
#cd ..
++++++++FAAD2+++++++++++
#wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
#tar zxvf faad2-2.7.tar.gz
#cd faad2-2.7
#./configure
#make
#make install
#cd ..
++++++++FAAC+++++++++++
#wget http://sourceforge.net/projects/faac/files/faac-src/faac-1.28/faac-1.28.tar.gz/download (http://172.16.1.100/faac-1.28.tar.gz)
#tar zxvf faac-1.28.tar.gz
#cd faac-1.28
#cd common/mp4v2/
#vi mpeg4ip.h
126G—定位到126行后删除这一行,保持退出
回到faac-1.28目录下:cd ..
Cd ..
#./configure
#make
#make install
#cd ..
++++++++Xvid+++++++++++
#wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
#tar zxvf xvidcore-1.3.2.tar.gz
#cd xvidcore/build/generic
#./configure
#make
#make install
#cd ..
++++++++ffmpeg+++++++++++
#git clone git://source.ffmpeg.org/ffmpeg
#cd ffmpeg
#./configure --prefix=/opt/ffmpeg/ --enable-version3 --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-shared --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads
#make && make install
#cd ..
++++++++ zlib+++++++++++
Wget http://www.zlib.net/ zlib-1.2.8.tar.gz
#tar xzvf zlib-1.2.8.tar.gz
#cd zlib-1.2.8
#./configure –prefix-/usr/local/zlib
#make && make install
修改/etc/ld.so.conf如下:
include ld.so.conf.d/*.conf
/lib
/lib64
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/ffmpeg/lib
#ldconfig
二、安装Nginx相关模块
#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
#git clone git://github.com/arut/nginx-rtmp-module.git
#wget http://sourceforge.net/projects/pcre/files/pcre/8.12/pcre-8.12.tar.gz
#tar zxvf pcre-8.12.tar.gz
#cd pcre-8.12
#./configure –prefix=/usr/local/pcre
#make && make install
#cd ..
下载nginx-1.5.3安装包
#wget http://nginx.org wget http://nginx.org/download/nginx-1.5.3.tar.gz
#tar zxvf nginx-1.5.3.tar.gz
#cd nginx-1.5.3
#groupadd www
#useradd -g www www
#cd ..
#cd nginx_mod_h264_streaming-2.2.7/src
#vi ngx_http_streaming_module.c
Delete if(r->zero_in_uri){}
#cd ..
#cd nginx-1.5.3
#./configure --prefix=/usr/local/nginx --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_ssl_module --with-pcre=/root/ softsource /pcre-8.12 --with-zlib=/root/softsource /zlib-1.2.8 --user=www --group=www --with-http_flv_module --with-http_stub_status_module --add-module=../nginx-rtmp-module
#make
#make install
#cd ..
三、安装yamdi
yadmi的作用是为flv文件添加关键帧,才能实现拖动播放
下载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
#cd ..
使用方法:yamdi -i input.flv -o out.flv
给input.flv文件 添加关键帧,输出为out.flv文件
四、修改nginx主配置文件,配置虚拟主机(注意空格)
#cd /usr/local/nginx/conf
#vi 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 8081;
server_name 172.16.10.200;###设置主机ip
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:
}
Location ~ {
root html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
保存退出;
#cd ..
五、基本上已经设置完毕,但是此时我们测试的时候还需要一个支持拖拽播放的flash播放器,开源的JW Player就可以实现这样的功能
下载链接:http://blogimg.chinaunix.net/blog/upfile2/100607142612.rar
下载播放器后,上传到上面设置的/usr/local/nginx/html/目录下,并把flv视频文件也放到该目录下!
播放器放到与index.html同级。
这个时候需要安装rar:
#wget http://www.rarlab.com/rar/rarlinux-3.8.0.tar.gz
#tar zxvf rarlinux-3.8.0.tar.gz -C /usr/local
#yum install glibc.i686
#yum install libstdc++.so.6
此时,/usr/local/rar下就会有rar命令和unrar命令。
进入到nginx下的html文件夹下载视频播放工具player.swf
#cd
#cd /usr/local/nginx/html
#wget http://blogimg.chinaunix.net/blog/upfile2/100607142612.rar
#unrar –e 100607142612.rar
#ls –l
可以看到解压到的文件;
六、根据nginx的配置文件的中的配置设置端口号
#vi /etc/sysconfig/iptables
开放8081端口
#/sbin/service iptables restart
重启防火墙,设置生效
修改防火墙配置文件,所在目录/etc/sysconfig/iptables,在里面增加需要开通的端口号,如下:
1
2 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT
#增加的代码必须放在以下代码之上,否则不会起作用.
1
2 -A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
七、启动nginx后测试:
启动命令:
#/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
启动nginx的帮助文档:
#/usr/local/nginx/sbin/nginx -h
#/usr/local/nginx/sbin/nginx –s reload
查看nginx的配置是否正确:
#/usr/local/nginx/sbin/nginx –t
如果配置是正确的会显示如下内容:
Nginx.conf syntax is ok.
Nginx.conf test is successful.
http://127.0.0.1/player.swf?type=http&file=mp42.mp4
说明: #这里的127.0.0.1是自己的ip
#player.swf是我的JW Player播放器
#http是表示居于http分发方式
#mp42.mp4是我的flv视频文件