• Linux下ffmpeg交叉编译


    1 获取源代码

    git clone -b "branch" https://git.ffmpeg.org/ffmpeg.git

    “branch” 可以是以下的masterrelease/3.1等等,具体看需要使用哪个分支。

    5 hours ago master shortlog | log | tree
    4 days ago release/3.1 shortlog | log | tree
    4 days ago release/3.2 shortlog | log | tree
    4 days ago release/3.3 shortlog | log | tree
    3 weeks ago release/3.0 shortlog | log | tree
    2 months ago release/2.8 shortlog | log | tree
    12 months ago release/2.7 shortlog | log | tree
    12 months ago release/2.6 shortlog | log | tree
    12 months ago release/2.5 shortlog | log | tree

    2 Configure配置

    在源码的目录下调用configure脚本,通过 -h 查看相应的帮助,这里写了一个简单的脚本build-ffmpeg.sh;

    #!/bin/bash
    
    PREFIX=out
    TOOLCHAINS=/mnt/diska/X3399/source/buildroot/output/host/opt/ext-toolchain/bin
    CROSS_COMPILE=${TOOLCHAINS}/aarch64-linux-gnu-
    LOCAL_PATH=`pwd`
    CFLAGS="-Wall -pipe -fpic 
       -finline-limit=300 -ffast-math 
       -fstrict-aliasing -Werror=strict-aliasing 
       -fmodulo-sched -fmodulo-sched-allow-regmoves 
       -Wno-psabi -Wa,--noexecstack"
    EXTRA_CFLAGS=
    EXTRA_LDFLAGS=
    CPU_NAME=cortex-a72
    FFMPEG_FLAGS="--prefix=${PREFIX} 
       --target-os=linux 
       --arch=arm 
       --cpu=$CPU_NAME 
       --enable-cross-compile 
       --cross-prefix=${CROSS_COMPILE} 
       --enable-shared 
       --disable-symver 
       --disable-doc 
       --disable-ffplay 
       --disable-ffmpeg 
       --disable-ffprobe 
       --disable-ffserver 
       --disable-avdevice 
       --disable-avfilter 
       --disable-muxers 
       --disable-filters 
       --disable-devices 
       --disable-everything 
       --enable-protocols  
       --enable-parsers 
       --enable-demuxers 
       --disable-demuxer=sbg 
       --enable-decoders 
       --enable-bsfs 
       --enable-network 
       --enable-swscale  
       --enable-neon 
       --enable-version3 
       --disable-yasm 
       --disable-asm"
    
     #--enable-debug 
     #--disable-stripping 
     #--disable-optimizations 
    
     ./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$LDFLAGS $EXTRA_LDFLAGS"
    
     #make && make install

    3 报错处理

    如果在根目录下直接执行build-ffmpeg.sh脚本是无法成功安装ffmpeg的,首先这里会出现以下几个问题。

    报错1:

    错误内容:

    {your path to toolchians}/aarch64-linux-gnu-gcc is unable to create an executable file. C compiler test failed.

    解决方案:

    1. 打开configure文件;

    2. 搜索报错内容“C compiler test failed”,定位到以下内容,注释掉 die “C compiler test failed.” 或者修改 if 条件使得条件一直成立也是可以的。

      if test "$?" != 0; then
      echo "$cc is unable to create an executable file."
      if test -z "$cross_prefix" && ! enabled cross_compile ; then
          echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
          echo "Only do this if you know what cross compiling means."
      fi
      
      #   die "C compiler test failed."
      
      fi  

    报错2

    错误内容:

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solve the problem.

    解决方案:

    和报错1的解决方案类似,需要定位configure文件中的错误信息提示内容,

     die(){
         echolog "$@"
         cat <<EOF
    
     If you think configure made a mistake, make sure you are using the latest
     version from Git.  If the latest version fails, report the problem to the
     ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
     EOF
         if disabled logging; then
             cat <<EOF
     Rerun configure with logging enabled (do not use --disable-logging), and
     include the log this produces with your report.
     EOF
         else
             cat <<EOF
     Include the log file "$logfile" produced by configure as this will help
     solve the problem.
     EOF
         fi
     #    exit 1
     }
    

    简单粗暴一点将exit 1直接注释掉,这样就不会退出了,但是会遇到什么问题不得而知,至少目前可以成功安装了。

    报错3

    错误内容:

    aarch64-linux-gnu-gcc: error: missing argument to ‘-mcpu=’

    解决方案:

    configure 参数中加入 –cpu=$CPU_NAME 选项

    4 At last

    最后将out文件夹下的 文件copy到目标板上即可

  • 相关阅读:
    C# 全局热键
    Frida hook 初识
    xposed hook 复杂函数参数问题
    C# http post 中文乱码问题
    Fiddler 抓包https 问题
    C# HttpWebRequest 多线程超时问题
    Android Studio 无 Generate signed apk 菜单选项问题
    c#调用c++ dll const char* String类型转换问题。传值,与接收返回值问题
    C++中GB2312字符串和UTF-8之间的转换
    The underlying connection was closed: An unexpected error occurred on a send
  • 原文地址:https://www.cnblogs.com/unclemac/p/12783434.html
Copyright © 2020-2023  润新知