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. ...
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