1、安装PCRE库
到www.pcre.org 下载pcre-8.37.tar.gz
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.37
./configure
make
make install
2、安装zlib库
到www.zlib.net 下载zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./configure
make
make install
3、安装SSL
到www.openssl.org下载openssl-1.0.2g.tar.gz
tar -zxvf openssl-1.0.2g.tar.gz
./config
make
make install
4、到nginx.org 下载nginx
到https://github.com/arut/nginx-rtmp-module 下载:nginx-rtmp-module
解压缩
进入解压后的nginx
依次执行以下命令运行:
./configure --prefix=“安装目录” --add-module=“nginx-rtmp-module解压后的路径” --with-http_ssl_module
make -f objs/Makefile
make -f objs/Makefile install
5、配置
#推流配置,与http配置同级
rtmp {
server {
listen 2017;
publish_time_fix on;
application live {
live on;
allow publish all;
allow play all;
}
#用于HLS拉流
application vod {
live on;
hls on;
hls_path “推流目录”;
hls_fragment 5s;
}
#用于RTMP拉流
application app {
live on;
#record all;
#record_path /alidata/server/nginx/www;
}
}
#拉流配置,与http下server同级
server{
listen 8080;
location / {
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root “推流目录”;
add_header Cache-Control no-cache;
}
}
6、html拉流关键代码
//HLS拉流
<video controls autoplay>
<source src="http://192.168.1.104:8080/qq.m3u8" type="application/vnd.apple.mpegurl" />
<p class="warning">Your browser does not support HTML5 video.</p>
</video>
//RTMP拉流和推流网址一致
rtmp://192.168.1.104:2017/app/qq
7、ffmpeg模拟推流工具的安装
到http://ffmpeg.org/ 官网下载压缩包并解压缩
tar -xjvf ffmpeg-3.3.1.tar.bz2
到http://yasm.tortall.net/Download.html下载yasm并解压缩
tar -xvzf yasm-1.3.0.tar.gz
cd yasm-1.3.0/
./configure
make
make install
进入解压缩后的ffmpeg
./configure --enable-shared --prefix=/monchickey/ffmpeg
make
make install
vim /etc/ld.so.conf.d/ffmpeg.conf
添加一行内容: /monchickey/ffmpeg/lib 之后保存并退出,然后执行 ldconfig 使配置生效
然后cd /monchickey/ffmpeg/查看版本./ffmpeg -version正常
为了方便可以在/etc/profile文件中将ffmpeg命令添加进PATH中
sudo vim /etc/profile
找到export行,在下面一行添加
export PATH=/usr/local/ffmpeg/bin/:$PATH
保存后执行
source /etc/profile
8、模拟推流
ffmpeg -re -i aaa.mp4 -c copy -f flv rtmp://192.168.1.104:2017/vod/qq
9、参考网址
https://www.cnblogs.com/qazwsxwtc/p/5384967.html
https://www.cnblogs.com/freeweb/p/6897907.html
http://blog.csdn.net/enweitech/article/details/52485535
https://github.com/arut/nginx-rtmp-module
http://blog.csdn.net/redstarofsleep/article/details/45092147
http://www.360doc.com/content/15/0618/10/597197_478933808.shtml