阿里雲ECS+Nginx+nginx_rtmp_module+FFMPEG服務器搭建過程


Nginx下安裝nginx-rtmp-module+ffmpeg搭建流媒體服務器。
參考http://blog.csdn.net/redstarofsleep/article/details/45092147

阿里雲環境
1. 使用SecueCRT、FlashFXP連接購買的阿里雲ECS。
2. 一般購買后盤是初始化好的。第一次操作忽略這步。掛載新的盤時,可參考初始化盤https://jingyan.baidu.com/article/37bce2be0eeea01002f3a208.html
3. 在阿里雲買的是Ubuntu Java環境,所以需要安裝g++編譯器( apt-get install g++)。

Nginx安裝
參考:http://blog.csdn.net/redstarofsleep/article/details/45092127
1.下載(或從官網下載后上傳):
wget http://nginx.org/download/nginx-1.10.2.tar.gz
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
2.解壓四個包:tar -xzvf XXXXX.tar.gz。
3.安裝nginx:
cd /usr/src/nginx-1.10.2
./configure --prefix=/usr/nginx --with-pcre=/usr/src/pcre-8.40 --with-zlib=/usr/src/zlib-1.2.11 --with-openssl=/usr/src/openssl-fips-2.0.10
make
make install
進入objs執行./nginx(低版本進入sbin)啟動。ps -ef | grep nginx查看進程狀態。
4.測試
瀏覽器輸入http://公網IP,進入不顯示nginx啟動畫面。
原因:阿里雲安全組沒設置80端口對外,新增一組80端口公網http,https訪問的安全組規則即可。如何添加看阿里雲幫助。
5.結束進程。./nginx -s stop或者./nginx -s quit

nginx-rtmp-module安裝
cd /usr/src/nginx-1.10.2
./configure --add-module=/usr/src/nginx-rtmp-module
make && make install

ffmpeg及三方包安裝
編譯安裝FFmpeg 要支持xvid、x264、mp3、ogg、amr、faac
參考:http://blog.csdn.net/redstarofsleep/article/details/45092145
1.libx264需要nasm,yasm。
安裝yasm:
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
./configure ; make ; make install
安裝nasm:
wget http://www.nasm.us/pub/nasm/releasebuilds/2.13/nasm-2.13.tar.gz
安裝libx264:
注意解壓格式tar -jxvf last_x264.tar.bz2
安裝libx264:
wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
./configure ; make ; make install
安裝libaac...等包。
另參考安裝FFmpeg:

libfaac faac格式的編解碼包
libmp3lame mp3格式編解碼包
libopencore-amrwb libopencore-amrnb amr格式編解碼包
libx264 x264格式編解碼包
libvorbis ogg格式編解碼包
libxvid xvid格式編解碼包

開始安裝(有些包下載可能需要翻牆)
faac
wget http://softlayer-dal.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
tar zxf faac-1.28.tar.gz
cd faac-1.28
./configure prefix=/usr/local/
make #./common/mp4v2/mpeg4ip.h strcasestr 重復定義報錯,暫時注釋其。
make install

lame : 參考:http://www.linuxfromscratch.org/blfs/view/svn/multimedia/lame.html
wget http://downloads.sourceforge.net/lame/lame-3.99.5.tar.gz
tar -zxvf lame-3.99.5.tar.gz
cd lame*
說有個編譯錯誤解決下:
case $(uname -m) in
i?86) sed -i -e '/xmmintrin\.h/d' configure ;;
esac
./configure --prefix=/usr --enable-mp3rtp --disable-static &&
make
# make test 可以測試
make pkghtmldir=/usr/share/doc/lame-3.99.5 install

libtheora:
參考http://www.linuxfromscratch.org/blfs/view/svn/multimedia/libtheora.html
libogg:
./configure --prefix=/usr \
--disable-static \
--docdir=/usr/src/ffmpeg/libogg-1.3.2 &&
make && make check && make install

libtheora:
sed -i 's/png_\(sizeof\)/\1/g' examples/png2theora.c &&
./configure --prefix=/usr --disable-static &&
make && make install

libvorbis:
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz
sed -i '/components.png \\/{n;d}' doc/Makefile.in
./configure --prefix=/usr --disable-static &&
make
make install &&
install -v -m644 doc/Vorbis* /usr/src/ffmpeg/libvorbis-1.3.5

opencore-amr
wget http://iweb.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz
tar zxf opencore-amr-0.1.3.tar.gz
cd opencore-amr
./configure prefix=/usr/local/
make && make install

ogg
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz
xz -d libogg-1.3.2.tar.xz
tar xf libogg-1.3.2.tar
cd libogg-1.3.2
./configure prefix=/usr/local/
make && make install

xvid
wget http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz
tar zxf xvidcore-1.3.3.tar.gz
cd xvidcore/build/generic/ #注意路徑
./configure prefix=/usr/local/
make && make install

pkg-config:依賴 glib. http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.53/glib-2.53.2.tar.xz
安裝參考:http://blog.csdn.net/chenhezhuyan/article/details/9455625

ffmpeg
wget http://ffmpeg.org/releases/ffmpeg-2.4.3.tar.bz2
tar jxf ffmpeg-2.4.3.tar.bz2
cd ffmpeg-2.4.3
失敗:
./configure --enable-libxvid --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-zlib --enable-bzlib --enable-libvorbis
部分包安裝失敗。先去掉部分包依賴,成功:
./configure --enable-libxvid --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-gpl --enable-version3 --enable-shared --enable-zlib --enable-libvorbis
make#wait about 10 minutes
make install

OVER! 原文鏈接:http://www.linuxidc.com/Linux/2015-02/112693.htm

執行 ffmpeg ,報錯。分析參考(http://blog.csdn.net/kaka20080622/article/details/40260423):
ldd `which ffmpeg`
信息:
root:/usr/src/ffmpeg/ffmpeg-3.3.1# ldd `which ffmpeg`
linux-vdso.so.1 => (0x00007fff54cc1000)
libavdevice.so.57 => not found
libavfilter.so.6 => not found
libavformat.so.57 => not found
libavcodec.so.57 => not found
libpostproc.so.54 => not found
libswresample.so.2 => not found
libswscale.so.4 => not found
libavutil.so.55 => not found
解決:
#find / | grep -E "libavdevice.so.57|libavfilter.so.6|libavformat.so.57|libavcodec.so.57|libpostproc.so.54|libswresample.so.2|libswscale.so.4|libavutil.so.55"
#edit /etc/ld.so.conf #添加find到的路徑
include ld.so.conf.d/*.conf
/usr/local/lib
#ldconfig
#ffmpeg 顯示可以使用了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM