CentOS安装视频转换FFmpeg和切割工具segmenter

1.最偷懒的方式就是yum安装了,自动解决依赖。不过CentOS系统默认无FFmpeg源,企业版 Linux 附加软件包EPEL源也不包含,需要手动添加yum源配置/etc/yum.repos.d/dag.repo:

[dag]name=Dag RPM Repository for Red Hat Enterprise Linuxbaseurl=http://apt.sw.be/RedHat/el$releasever/en/$basearch/daggpgcheck=0enabled=1

2.在线安装FFmpeg

yum -y install ffmpeg

二、编译安装FFmpeg

yum安装FFmpeg比源码编译安装省时省力,但缺点也很明显,版本过老,为0.6.5版,最新版已为2.6.3,新旧版很多参数有所差异,旧版支持的格式也没有新版丰富。

源码编译安装FFmpeg非常需要耐心,每添加一种需要支持的格式就需要有相应的多媒体格式开发库。文中所使用的软件版本皆为最新版。

1.安装autoconf

cd /App/srcwget tar xvf autoconf-2.69.tar.xzcd autoconf-2.69./configuremakemake install

2. 安装automake

cd /App/srcwget tar xvf automake-1.15.tar.xzcd automake-1.15./configuremakemake install

3. 安装libtool(FAAC需要)

cd /App/srcwget tar xvf libtool-2.4.6.tar.xzcd libtool-2.4.6./configuremakemake install

4. 安装yasm支持汇编优化(FFmpeg需要)

cd /App/srcwget tar xvf yasm-1.3.0.tar.gzcd yasm-1.3.0./configuremakemake install

5. 添加动态链接库配置

echo ‘/usr/local/lib’ >> /etc/ld.so.conf.d/local.conf

6. 安装MP3支持库LAME

cd /App/srcwget tar xvf lame-3.99.5.tar.gzcd lame-3.99.5./configuremakemake install

7. 安装AAC支持库FAAC

make时报错:mpeg4ip.h:126: 错误:对‘char* strcasestr(const char*, const char*)’的新声明

需要修改common/mp4v2/mpeg4ip.h第123行至129行内容:

#ifdef __cplusplusextern “C” {#endifchar *strcasestr(const char *haystack, const char *needle);#ifdef __cplusplus}#endif

修改为:

1234567 #ifdef __cplusplusextern “C++” {#endifconst char *strcasestr(const char *haystack, const char *needle);#ifdef __cplusplus}#endif

cd /App/srcwget tar xvf faac-1.28.tar.bz2cd faac-1.28./bootstrap./configure –with-mp4v2 #按前文修改mpeg4ip.h内容makemake install

8. 安装AMR支持库opencore-amr

cd /App/srcwget tar xvf opencore-amr-0.1.3.tar.gzcd opencore-amr-0.1.3./configuremakemake install

9. 安装通用音乐音频编码格式支持库libvorbis

# libvorbis需要libogg,先安装libogg库cd /App/srcwget tar xvf libogg-1.3.2.tar.xzcd libogg-1.3.2./configuremakemake installcd /App/srcwget tar xvf libvorbis-1.3.5.tar.xzcd libvorbis-1.3.5./configuremakemake install

10. 安装x264库支持H.264视频转码

cd /App/srcgit clone git://git.videolan.org/x264.gitcd x264./configure –enable-sharedmakemake install

11. 安装Xvid库支持MPEG-4转码

cd /App/srcwget tar xvf xvidcore-1.3.3.tar.bz2cd xvidcore/build/generic./configuremakemake install

12. 安装Theora视频压缩支持库

cd /App/srcwget tar xvf libtheora-1.1.1.tar.xzcd libtheora-1.1.1./configuremakemake install

13. 安装NUT支持库

安装时64位Linux系统需要修改文件config.mak

在最后一个CFLAGS下一行增加:

CFLAGS += -fPIC

否则安装FFmpeg make时报错:

/usr/local/lib/libnut.a: could not read symbols: Bad value

cd /App/srcsvn co svn://svn.mplayerhq.hu/nut/src/trunk libnutcd libnut./configuremakemake install

14. 安装VP8/VP9编解码支持库

cd /App/srcgit clone cd libvpx./configure –enable-sharedmakemake install

15. 安装FFmpeg最新版

cd /App/srcwget tar xvf ffmpeg-2.6.3.tar.bz2cd ffmpeg-2.6.3./configure –enable-version3 –enable-libvpx –enable-libfaac –enable-libmp3lame –enable-libvorbis –enable-libx264 –enable-libxvid –enable-gpl –enable-postproc –enable-nonfree –enable-avfilter –enable-pthreads –enable-libnut –enable-libtheora –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-sharedmakemake installldconfig

16. 安装segmenter

git clone https://github.com/johnf/m3u8-segmentercd m3u8-segmenterPKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configuremakemake installln -s /usr/local/bin/m3u8-segmenter /usr/local/bin/segmenter

三、 编译安装注意事项

1. 可能发现编译FFmpeg或者其他支持库时,即使相关的所有依赖也编译安装上了,仍然make报错,主要的原因还是由于依赖的库版本冲突,编译时调用的是yum安装时自动下载安装的旧版本依赖库。此时的方法就是卸掉所有yum安装的旧版本FFmpeg和相关的依赖软件包或者重新找台新的纯净的系统重新开始安装,或者使用Ubuntu Server最新版,一般Ubuntu Server最新版FFmpeg版本还是比较新的,直接执行命令 sudo apt-get install ffmpeg 会自动安装FFmpeg和相关依赖。

看自家总在期待,不知将来好歹,新乐吧总在不断等待,

CentOS安装视频转换FFmpeg和切割工具segmenter

相关文章:

你感兴趣的文章:

标签云: