您的位置:首页 > 运维架构 > Nginx

使用Nginx+FFmpeg搭建HLS直播转码服务器

2016-04-26 16:18 911 查看
目的:使Nginx支持Rtmp协议推流,并支持HLS分发功能及FFmpeg转码多码率功能。

一、准备工作

模块:nginx-rtmp-module-master(支持rtmp协议)

下载地址:
http://nginx.org https://github.com/arut/nginx-rtmp-module
1、安装依赖包:

#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工具:

#mkdir soft-source

#cd soft-source

#wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
#tar xzvf git-latest.tar.gz 

#cd git-2013-02-04

#autoconf

#./configure

#make && make install

# git --version

git version 1.8.1.GIT

#cd ..

【错误处理】

如果 git-latest.tar.gz大小为0,请下载git-latest-tar.xz

然后xz -d git-latest.tar.xz解压为.tar

再tar xvf git-latest.tar

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
#tar xzvf lame-3.99.5.tar.gz

#cd lame-3.99.5

#./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+++++++++++

#git clone http://git.chromium.org/webm/libvpx.git
#cd libvpx

#./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://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
#tar zxvf faac-1.28.tar.gz

#cd faac-1.28

#./configure

#make

#make install

#cd ..

【错误处理】

编译FAAC-1.28时遇到错误:

mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’

解决方法:

从123行开始修改此文件mpeg4ip.h,到129行结束。

修改前:

#ifdef __cplusplus

extern "C" {

#endif

char *strcasestr(const char *haystack, const char *needle);

#ifdef __cplusplus

}

#endif

修改后:

#ifdef __cplusplus

extern "C++" {

#endif

const char *strcasestr(const char *haystack, const char *needle);

#ifdef __cplusplus

}

#endif

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

【错误处理】

如果提示libvpx decoder version must be >=0.91,请从Baidu搜索一下libvpx-v1.1.0.tar.bz下载。

bzip2 -d  libvpx-v1.1.0.tar.bz2

tar xvf  libvpx-v1.1.0.tar.bz2

cd libvpx-v1.1.0

./configure --enable-shared --enable-vp8

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

【说明】

动态装入器找到共享库要依靠两个文件 — /etc/ld.so.conf 和 /etc/ld.so.cache。

安装完成后,ffmpeg位于/opt/ffmpeg/bin目录下。

Linux下编译FFmpeg之下载源文件并编译 http://www.linuxidc.com/Linux/2012-02/54565.htm

Linux 编译升级 FFmpeg 步骤 http://www.linuxidc.com/Linux/2013-08/88190.htm

CentOS 5.6 上安装 FFMPEG http://www.linuxidc.com/Linux/2011-09/42793.htm

Ubuntu下安装FFmpeg http://www.linuxidc.com/Linux/2012-12/75408.htm

Ubuntu 12.04下编译ffmpeg  http://www.linuxidc.com/Linux/2013-02/78857.htm

Ubuntu 14.04下PPA安装FFmpeg 2.2.2  http://www.linuxidc.com/Linux/2014-05/101322.htm

更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2015-01/111182p2.htm

转贴:http://www.linuxidc.com/Linux/2015-01/111182.htm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: