ffmpeg编译安装

来源:互联网 发布:淘宝店usa商城是正品吗 编辑:程序博客网 时间:2024/06/14 08:36

1.安装依赖包

  1. 安装autoconf

    cd /root/sourcewget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz    tar xvf autoconf-2.69.tar.xzcd autoconf-2.69./configuremakemake install
  2. 安装automake

    cd /root/sourcewget http://ftp.gnu.org/gnu/automake/automake-1.15.tar.xz  tar xvf automake-1.15.tar.xzcd automake-1.15./configuremakemake install
  3. 安装libtool(FAAC需要)

    cd /root/sourcewget http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xztar xvf libtool-2.4.6.tar.xzcd libtool-2.4.6./configuremakemake install
  4. 安装yasm支持汇编优化(FFmpeg需要)

    cd /root/sourcewget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gztar xvf yasm-1.3.0.tar.gzcd yasm-1.3.0./configuremakemake install
  5. 安装MP3支持库LAME

    cd /root/sourcewget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz  tar xvf lame-3.99.5.tar.gzcd lame-3.99.5./configuremakemake install
  6. 安装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

    修改为:

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

    编译

    cd /root/sourcewget http://jaist.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.bz2 tar xvf faac-1.28.tar.bz2cd faac-1.28./bootstrap./configure --with-mp4v2 #按前文修改mpeg4ip.h内容makemake install
    主要提示:可能受限于FFmpeg版本的缘故,安装了AAC库,在ffmpeg-3.2.4版本下编译ffmpeg,使用--enable-libfaac选项时,会报找不到libfaac错误。百度了一番,看了FFmpeg的WiKi百科,发现它使用libfdk-aac库替代libfaac库,安装后测试果然解决问题。
    cd /root/sourcewget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/mastertar xzvf fdk-aac.tar.gzcd mstorsjo-fdk-aac*autoreconf -fiv./configure --disable-shared --with-pic#--with-pic 很重要,一定要带上,不然在编译FFmpeg时会报错makemake install
  7. 安装AMR支持库opencore-amr

    cd /root/sourcewget http://jaist.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gztar xvf opencore-amr-0.1.3.tar.gzcd opencore-amr-0.1.3./configuremakemake install
  8. 安装通用音乐音频编码格式支持库libvorbis

    支持库libvorbis需要依赖libogg,先安装libogg库
    cd /root/sourcewget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xztar xvf libogg-1.3.2.tar.xzcd libogg-1.3.2./configuremakemake install
    再安装libvorbis库
    cd /root/sourcewget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xztar xvf libvorbis-1.3.5.tar.xzcd libvorbis-1.3.5./configuremakemake install
  9. nasm -v查看nasm是不是最新版,安装最新nasm如下命令:
    sudo yum-config-manager --add-repo http://www.nasm.us/nasm.reposudo yum install nasm
  10. 安装x264库支持H.264视频转码

    cd /root/sourcegit clone git://git.videolan.org/x264.gitcd x264./configure --enable-sharedmakemake installx264依赖ffmpeg动态库,安装前先要安装ffmpeg动态库(./configure --enable-shared)
  11. 安装Xvid库支持MPEG-4转码

    cd /root/sourcewget http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.bz2tar xvf xvidcore-1.3.3.tar.bz2cd xvidcore/build/generic./configuremakemake install
  12. 安装Theora视频压缩支持库

    cd /root/sourcewget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.xztar xvf libtheora-1.1.1.tar.xzcd libtheora-1.1.1./configuremakemake install
  13. 安装NUT支持库

    该软件需要用svn获取源代码,svn可以直接用yum install svn来装。

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

    # 在最后一个CFLAGS下一行增加:CFLAGS += -fPIC

    否则安装FFmpeg make时报错:

    /usr/local/lib/libnut.a: could not read symbols: Bad value
    cd /root/sourcesvn co svn://svn.mplayerhq.hu/nut/src/trunk libnutcd libnut./configure#configure后修改上述的config.makmakemake install
  14. 安装VP8/VP9编解码支持库

    cd /root/source#git clone http://git.chromium.org/webm/libvpx.git#直接获取比较好,没装gitwget -O libvpx.zip https://codeload.github.com/webmproject/libvpx/zip/masterunzip libvpx.zipcd libvpx./configure --enable-sharedmakemake install
  15. 安装FFmpeg最新版

    cd /root/sourcewget http://ffmpeg.org/releases/ffmpeg-3.2.4.tar.bz2tar xvf ffmpeg-3.2.4.tar.bz2cd ffmpeg-3.2.4#老版本的--enable-libfaac,已替换为--enable-libfdk-aac./configure --enable-version3 --enable-libvpx --enable-libfdk-aac --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-sharedmake#若出现下述错误,在此修改config.mak文件,然后再make,切记别重新configuremake install

    若make的时候,报以下错误

    /usr/bin/ld: libavcodec/mqc.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIClibavcodec/mqc.o: error adding symbols: Bad valuecollect2: error: ld returned 1 exit status

    解决方法是:

    #config.mak L75加入 -fPIC,然后重新编译#直接替换,顺序可能不一样HOSTCFLAGS=-O3 -g -std=c99 -Wall -fPIC
  16. 添加动态链接库配置

    echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf#更新缓存ldconfig
    安装到这里就大功告成啦,一路安装真心不容易,查看下版本:
    [root@localhost djnj]# ffmpeg -versionffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developersbuilt with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)configuration: --enable-version3 --enable-libvpx --enable-libfdk-aac --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-sharedlibavutil      55. 34.101 / 55. 34.101libavcodec     57. 64.101 / 57. 64.101libavformat    57. 56.101 / 57. 56.101libavdevice    57.  1.100 / 57.  1.100libavfilter     6. 65.100 /  6. 65.100libswscale      4.  2.100 /  4.  2.100libswresample   2.  3.100 /  2.  3.100libpostproc    54.  1.100 / 54.  1.100

    看到这个满满的幸福和成就感。



作者:恒啸寰宇
链接:http://www.jianshu.com/p/99a80aa9a2d0
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。