码迷,mamicode.com
首页 > 系统相关 > 详细

基于linux平台的FFmpeg安装部署

时间:2018-03-04 14:39:06      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:ffmpeg   linux   mp4   jpeg   

FFmpeg安装部署

  1. 系统环境
    [root@ceshiji ~]# iostat
    Linux 2.6.32-573.3.1.el6.x86_64 (ceshiji)   2018年03月04日     _x86_64_    (8 CPU)
    [root@ceshiji ~]# cat /etc/redhat-release
    CentOS release 6.7 (Final)
    [root@ceshiji ~]# getenforce
    Disabled
  2. 安装所需包或插件
    (1)faac-1.28.tar.gz
    下载地址:http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
    tar -zxvf  faac-1.28.tar.gz
    cd faac-1.28
    ./configure
    make && make install
    将 faac-1.28/common/mp4v2/mpeg4ip.h 第 123行~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

    如不安装会出现下面的报错信息:

    make[3]: 正在进入目录 `/home/tarena/project/jpg to mp4/faac-1.28/common/mp4v2‘  
    if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../include   -Wall -g -O2 -MT 3gp.o -MD -MP -MF ".deps/3gp.Tpo" -c -o 3gp.o 3gp.cpp; \  
    then mv -f ".deps/3gp.Tpo" ".deps/3gp.Po"; else rm -f ".deps/3gp.Tpo"; exit 1; fi  
    In file included from mp4common.h:29:0,  
                 from 3gp.cpp:28:  
    mpeg4ip.h:126:58: 错误: 对‘char* strcasestr(const char*, const char*)’的新声明  
    /usr/include/string.h:369:28: 错误: 使旧的声明‘const char* strcasestr(const char*, const char*)’出现歧义  
    make[3]: *** [3gp.o] 错误 1  
    make[3]:正在离开目录 `/home/tarena/project/jpg to mp4/faac-1.28/common/mp4v2‘  
    make[2]: *** [all-recursive] 错误 1  
    make[2]:正在离开目录 `/home/tarena/project/jpg to mp4/faac-1.28/common‘  
    make[1]: *** [all-recursive] 错误 1  
    make[1]:正在离开目录 `/home/tarena/project/jpg to mp4/faac-1.28‘  
    make: *** [all] 错误 2<strong>  
    </strong>  

    (2)lame-3.97.tar.gz

    下载地址:http://downloads.sourceforge.net/lame/lame-3.97.tar.gz
    tar -zxvf lame-3.97.tar.gz
    cd lame-3.98.4
    ./configure
    make && make install
    如不安装会出现下面的报错信息:
    ERROR: libmp3lame >= 3.98.3 not found

    (3)opencore-amr-0.1.2.tar.gz

    下载地址:http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/0.1.2/opencore-amr-0.1.2.tar.gz
    tar -zxvf opencore-amr-0.1.2.tar.gz
    cd opencore-amr-0.1.2
    ./configure
    make && make install
    如不安装会出现下面的报错信息:
    ERROR: libopencore_amrnb not found

    (4)libogg-1.3.3.tar.xz

    下载地址:wget https://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.xz
    tar -xf libogg-1.3.3.tar.xz
    ./configure --prefix=/usr            --disable-static         --docdir=/usr/share/doc/libogg-1.3.3 
    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.
    configure: error: must have Ogg installed!

    (5)libvorbis-1.3.5.tar.gz

    下载地址:https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz
    tar -xf libvorbis-1.3.5.tar.xz
    cd libvorbis-1.3.5
    ./configure
    make && make install
    如不安装会出现下面报错信息:
    ERROR: libvorbis not found

    (6)x264

    下载地址:wget http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20170213-2245-stable.tar.bz2
    tar -jxf x264-snapshot-20170213-2245-stable.tar.bz2
    cd x264-snapshot-20170213-2245-stable/
    ./configure --disable-asm --enable-static --enable-shared
    make && make install
    如不安装会出现下面报错信息:
    ERROR: libx264 not found
    ERROR: libx264 must be installed and version must be >= 0.118.
    重新编译安装libx264时,一定需要把电脑里面之前的版本给删除掉,在/usr 或者/usr/local下,在编译x264的时候加--enable-static --enable-shared,如果不加参数,只能编译出x264的执行文件出来,install到/usr/bin目录下面。
    按如下方法寻找:
    whereis libx264
    cd /usr/local/lib
    rm -rf libx264.*

    (7)xvidcore-1.2.2.tar.gz

    下载地址:http://downloads.xvid.org/downloads/xvidcore-1.2.2.tar.gz
    tar -xf xvidcore-1.2.2.tar.gz
    cd xvidcore/build/generic
    ./configure
    make && make install
    如不安装会出现下面报错信息:
    ERROR: libxvid not found
  3. 安装ffmpeg
    下载地址:https://ffmpeg.org/releases/ffmpeg-3.2.7.tar.gz
    tar -zxf ffmpeg-3.2.7.tar.gz
    cd ffmpeg-3.2.7 
    ./configure --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-libmp3lame --disable-yasm
    make && make install
    如出现下面报错信息:
    libavcodec/libx264.c: 在函数‘X264_init_static’中:
    libavcodec/libx264.c:892: 错误:‘x264_bit_depth’未声明(在此函数内第一次使用)
    make: *** [libavcodec/libx264.o] 错误 1
    解决方法:
    更换libx264版本,重新编译安装,把编译文件清理下,命令:make clean
    如出现如下报错:
    yasm/nasm not found or too old. 
    解决方法:
    安装yasm  或者按照提示直接在配置上添加 --disable-yasm
  4. 验证ffmpeg是否安装正确
    cd /usr/local/ffmpeg/bin
    ./ffmpeg -version
    报错信息如下:
    ./ffmpeg: error while loading shared libraries: libavdevice.so.57: cannot open shared object file: No such file or directory
    解决方法:
    pwd
    /data3/ceshiji/ffmpeg/x264-snapshot-20170213-2245-stable
    cp libx264.so.148 /usr/lib/
    修改文件 /etc/ld.so.conf 内容增加 /usr/local/ffmpeg/lib/ 
    echo "/usr/local/ffmpeg/lib/" >>  /etc/ld.so.conf  
    使之生效:
    #ldconfig
    ./ffmpeg -version
    ffmpeg version 3.2.7 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
    configuration: --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-libmp3lame --disable-yasm
    libavutil      55. 34.101 / 55. 34.101
    libavcodec     57. 64.101 / 57. 64.101
    libavformat    57. 56.101 / 57. 56.101
    libavdevice    57.  1.100 / 57.  1.100
    libavfilter     6. 65.100 /  6. 65.100
    libswscale      4.  2.100 /  4.  2.100
    libswresample   2.  3.100 /  2.  3.100
    libpostproc    54.  1.100 / 54.  1.100
  5. ffmpeg建立软连接
    两种方法均可:
    (1)ln -s /usr/local/ffmpeg/bin/ffmpeg  /usr/local/bin/ffmpeg
    (2)export PATH=/usr/local/ffmpeg/bin/:$PATH  
    永久性的:  
    echo "export PATH=/usr/local/ffmpeg/bin/:$PATH" >> /etc/profile 
    立即生效执行:  
    source /etc/profile  
  6. 基本命令
    (1)ffmpeg -help
    (2)ffmpeg -version
    (3)ffmpeg -codecs

基于linux平台的FFmpeg安装部署

标签:ffmpeg   linux   mp4   jpeg   

原文地址:http://blog.51cto.com/wutengfei/2082761

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!