zoukankan      html  css  js  c++  java
  • FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。

    官网:http://ffmpeg.org

    一、FFmpeg安装

    安装依赖包:

    yum install  libtheora-devel  libvorbis-devel
    • 1

    FFmpeg编译安装:

    由于系统不同,会导致依赖也不尽相同,需根据报错信息逐渐安装依赖

       可以自己到官网下载包

    wget http://ffmpeg.org/releases/ffmpeg-4.4.tar.bz2
    yum -y install bzip2 tar jxvf ffmpeg-4.4.tar.bz2 cd ffmpeg-4.4 # 如下是个人需要的编译参数,可以根据实际情况增减
    ./configure --prefix=/data/server/ffmpeg --enable-shared --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-postproc --enable-avfilter --enable-pthreads --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid  --enable-decoder=libx264 --disable-x86asm --enable-encoder=libx264
     make && make install
    

    安装后,查看版本

    /data/server/ffmpeg/bin/ffmpeg -version

    转码:

    ffmpeg -i input.mp4 output.avi

    二、FFmpeg安装错误解决

    1 tar (child): lbzip2: Cannot exec: No such file or directory 解决方法

    今天用tar命令解压文件的时候出错了,信息如下:

    tar (child): lbzip2: Cannot exec: No such file or directory 
    tar (child): Error is not recoverable: exiting now 
    tar: Child returned status 2 
    tar: Error is not recoverable: exiting now

    解决方法很简单,只要安装bzip2就行了,yum安装的命令如下:

    yum -y install bzip2

    如果虚拟机无法联网,也可以源码安装,下载:bzip2-1.0.6.tar,安装过程如下:

    tar zxvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6/
    #为编译做准备,创建libbz2.so动态链接库(这一步很重要,安装python的时候如果没有这一步,python安装不上bz2模块):
    make -f Makefile-libbz2_so
    make && make install

    2 $ git clone https://bitbucket.org/multicoreware/x265_git.git
    $ cd x265/build/linux
    $ ./make-Makefiles.bash
    $ make
    make install

    在安装ffmpeg4 --enable-libx265出现ERROR: x265 not found using pkg-config的问题
    解决问题三步走
    第一步:先查看错误日志文件vi ffbuild/config.log,查明出现错误原因
    我这里是找不到x265.pc文件路径

    第二步:当前终端执行命令添加环境变量export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig(路径是你安装x265的路径,按自己的修改添加即可)
    如果是线程函数的问题那就在生成的x265.pc文件中Libs.private这一行添加链接库 -lpthread,具体原因按照第一步分析
    第三步:ok

    有的包下载缓慢,备用下载地址: http://pan.baidu.com/s/1hsEeSNM

    • 3 报错:yasm/nasm not found or too old. Use --disable-yasm for a crippled build
    # rpm包存在的话,可以直接yum安装 yasm,没有则编译安装
    wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
    tar -zxvf  yasm-1.3.0.tar.gz
     ./configure  && make  && make install
    • 4 报错:ERROR: libfdk_aac not found
    https://sourceforge.net/projects/opencore-amr/files/fdk-aac/
    下载fdk-aac-0.1.6.tar.gz
    ./configure&& make && make install

    make 的时候报错
    ./libtool: line 990: g++: command not found报错信息
    于是直接yum -y install gcc* 然后继续make 
    OK 通过~~
    主要提示:可能受限于FFmpeg版本的缘故,安装了AAC库,在ffmpeg-3.2.4版本下编译ffmpeg,使用--enable-libfaac选项时,会报找不到libfaac错误。百度了一番,看了FFmpeg的WiKi百科,发现它使用libfdk-aac库替代libfaac库,安装后测试果然解决问题。
    cd /root/source
    wget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master
    tar xzvf fdk-aac.tar.gz
    cd mstorsjo-fdk-aac*
    autoreconf -fiv
    报错
    Makefile.am:36: error: Libtool library used but 'LIBTOOL' is undefined

    解决方案:
    yum install libtool

    ./configure --disable-shared --with-pic
    #--with-pic 很重要,一定要带上,不然在编译FFmpeg时会报错
    make
    make install
    • 5 报错:ERROR: libtheora not found
    http://downloads.xiph.org/releases/theora/?C=M;O=D
    libtheora-1.2.0alpha1.tar.gz
    ./configure && make && make install
    • 如下报错:
    *** Could not run Ogg test program, checking why...
    *** The test program failed to compile or link. See the file config.log for the
    *** exact error that occured. This usually means Ogg was incorrectly installed
    *** or that you have moved Ogg since it was installed.
    http://downloads.xiph.org/releases/ogg/?C=M;O=D
    libogg-1.3.2.tar.gz
    ./configure && make && make install
    • 6 报错:ERROR: libvorbis not found
    http://downloads.xiph.org/releases/vorbis/
    libvorbis-1.3.3.tar.
    • 7 报错:ERROR: libmp3lame >= 3.98.3 not found
    http://downloads.sourceforge.net/lame
    我下到的是lame-3.99.5.tar.gz
    ./configure && make && make install
    • 8 报错:ERROR: libx264 not found
     git clone git://git.videolan.org/x264.git 或是   git clone https://git.videolan.org/git/x264.git
    ./configure --enable-shared  --disable-asm && make && make install
    • 9 报错:ERROR: libxvid not found
    wget http://downloads.xvid.org/downloads/xvidcore-1.3.5.tar.gz
    cd build/generic/
    ./configure && make && make install

    依赖包解决完之后编译出现

    WARNING: Option --enable-decoder=libx264 did not match anything
    WARNING: using libfdk without pkg-config
    WARNING: using libx264 without pkg-config

    原因是需要设置 PKG_CONFIG_PATH,通过pkg-config去指定路径自动寻找需要链接的依赖库,同时,就不需要使用

    --extra-cflags=-I、

    --extra-cxxflags=-I、

    --extra-ldflags=-L来指定依赖库路径

    使用方法:在./configure之前输入export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH(此路径为.pc文件所在路径),可使用

    echo $PKG_CONFIG_PATH查看

     
    • 库文件找不到时解决:
    ldd /data/server/ffmpeg/bin/ffmpeg  # 查看依赖库文件,找到no found的库文件
    find /  -name libavdevice.so    # 查找库文件位置
    vim  /etc/ld.so.conf     # 如存在,添加库文件位置
    /usr/local/lib
    ldconfig     # 重新加载,使新库文件生效

    来查看运行当前可执行文件需要哪些动态库

    复制代码
        cd   /data/server/ffmpeg/bin/ 
    ldd ffmpeg linux-vdso.so.1 => (0x00007fffcfeaf000) libavdevice.so.57 => not found libavfilter.so.6 => not found libavformat.so.57 => not found libavcodec.so.57 => not found libswresample.so.2 => not found libswscale.so.4 => not found libavutil.so.55 => not found libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f41d6d9e000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f41d6b7f000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f41d67b9000) /lib64/ld-linux-x86-64.so.2 (0x00007f41d70c7000)
    复制代码

    应该有很多人和我一样,不想编译FFMPEG之后还要动自己系统的环境,这时有一个简单的方法可以解决这个问题。就是在当前终端export一个环境变量。

     cd   /data/server/ffmpeg/bin/
     export LD_LIBRARY_PATH=lib/
    vim /etc/bashrc

    export LD_LIBRARY_PATH=/data/server/ffmpeg/lib/

       export PATH=$PATH:/data/server/ffmpeg/bin/


    还有找不见的

     [root@iZm5eeyc1al5vzh8bo57zyZ etc]# cat ld.so.conf
     include ld.so.conf.d/*.conf
     /usr/local/lib
     [root@iZm5eeyc1al5vzh8bo57zyZ etc]#

     cd /data/server/ffmpeg/lib

     ldconfig # 重新加载,使新库文件生效

  • 相关阅读:
    hdu 1028 Ignatius and the Princess III (n的划分)
    CodeForces
    poj 3254 Corn Fields (状压DP入门)
    HYSBZ 1040 骑士 (基环外向树DP)
    PAT 1071 Speech Patterns (25)
    PAT 1077 Kuchiguse (20)
    PAT 1043 Is It a Binary Search Tree (25)
    PAT 1053 Path of Equal Weight (30)
    c++ 常用标准库
    常见数学问题
  • 原文地址:https://www.cnblogs.com/xy51/p/9592849.html
Copyright © 2011-2022 走看看