美文网首页
使用android-ndk-r17c构建ffmpeg 4.2.1

使用android-ndk-r17c构建ffmpeg 4.2.1

作者: 北铭 | 来源:发表于2019-11-26 19:10 被阅读0次

    1.报fatal error: asm/types.h: No such file or directory

    /sysroot/usr/include/linux/types.h:21:23: fatal error: asm/types.h: No such file or directory
    #include <asm/types.h>
    

    解决方案:在--extra-cflags添加头文件目录

    --extra-cflags="-I$NDK/sysroot/usr/include -I$NDK/sysroot/usr/include/arm-linux-androideabi" \
    

    2.报./libavutil/avassert.h:30:20: fatal error: stdlib.h: No such file or directory

    ./libavutil/avassert.h:30:20: fatal error: stdlib.h: No such file or directory
    
     #include <stdlib.h>
    
    

    解决方案:在--extra-cflags添加

    --extra-cflags=" -isysroot $ISYSROOT"
    

    完整的构建脚本如下:

    # 配置NDK路径
    NDK=/Users/kevinchen/android-ndk-r17c
    # 指定了交叉编译环境,使其在编译过程中能够引用到 NDK 提供的原生标头和共享库文件
    SYSROOT=$NDK/platforms/android-23/arch-arm/
    ISYSROOT=$NDK/sysroot
    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64
    #声明方法
    function build_one
    {
    ./configure --prefix=$PREFIX --enable-shared --disable-static --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-avdevice --disable-symver --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --target-os=linux --arch=armeabi-v7a --enable-cross-compile --sysroot=$SYSROOT --extra-cflags="-Os -isysroot $ISYSROOT -fpic $ADDI_CFLAGS -I$NDK/sysroot/usr/include -I$NDK/sysroot/usr/include/arm-linux-androideabi" --extra-ldflags="$ADDI_LDFLAGS" $ADDITIONAL_CONFIGURE_FLAG
    make clean
    make
    make install
    }
    CPU=armeabi-v7a
    PREFIX=$(pwd)/android/$CPU
    ADDI_CFLAGS="-marm"
    build_one
    

    编译中可能会遇到的一些错误

    错误一
    libavcodec/aaccoder.c: In function 'search_for_ms':
    libavcodec/aaccoder.c:803:25: error: expected identifier or '(' before numeric constant
                         int B0 = 0, B1 = 0;
                             ^
    libavcodec/aaccoder.c:865:28: error: lvalue required as left operand of assignment
                             B0 += b1+b2;
                                ^
    libavcodec/aaccoder.c:866:25: error: 'B1' undeclared (first use in this function)
                             B1 += b3+b4;
                             ^
    libavcodec/aaccoder.c:866:25: note: each undeclared identifier is reported only once for each function it appears in
    make: *** [libavcodec/aaccoder.o] Error 1
    

    解决:将libavcodec/aaccoder.c文件B0变量替换成b0

    错误二
    libavcodec/hevc_mvs.c: In function 'derive_spatial_merge_candidates':
    libavcodec/hevc_mvs.c:208:15: error: 'y0000000' undeclared (first use in this function)
                 ((y ## v) >> s->ps.sps->log2_min_pu_size))
                   ^
    libavcodec/hevc_mvs.c:204:14: note: in definition of macro 'TAB_MVF'
         tab_mvf[(y) * min_pu_width + x]
                  ^
    libavcodec/hevc_mvs.c:274:16: note: in expansion of macro 'TAB_MVF_PU'
         (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
                    ^
    libavcodec/hevc_mvs.c:368:23: note: in expansion of macro 'AVAILABLE'
         is_available_b0 = AVAILABLE(cand_up_right, B0) &&
                           ^
    libavcodec/hevc_mvs.c:208:15: note: each undeclared identifier is reported only once for each function it appears in
                 ((y ## v) >> s->ps.sps->log2_min_pu_size))
                   ^
    libavcodec/hevc_mvs.c:204:14: note: in definition of macro 'TAB_MVF'
         tab_mvf[(y) * min_pu_width + x]
                  ^
    libavcodec/hevc_mvs.c:274:16: note: in expansion of macro 'TAB_MVF_PU'
         (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
                    ^
    libavcodec/hevc_mvs.c:368:23: note: in expansion of macro 'AVAILABLE'
         is_available_b0 = AVAILABLE(cand_up_right, B0) &&
                           ^
    libavcodec/hevc_mvs.c:207:15: error: 'x0000000' undeclared (first use in this function)
         TAB_MVF(((x ## v) >> s->ps.sps->log2_min_pu_size),                     \
                   ^
    libavcodec/hevc_mvs.c:204:34: note: in definition of macro 'TAB_MVF'
         tab_mvf[(y) * min_pu_width + x]
                                      ^
    libavcodec/hevc_mvs.c:274:16: note: in expansion of macro 'TAB_MVF_PU'
         (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
                    ^
    libavcodec/hevc_mvs.c:368:23: note: in expansion of macro 'AVAILABLE'
         is_available_b0 = AVAILABLE(cand_up_right, B0) &&
                           ^
    libavcodec/hevc_mvs.c: In function 'ff_hevc_luma_mv_mvp_mode':
    libavcodec/hevc_mvs.c:208:15: error: 'y0000000' undeclared (first use in this function)
                 ((y ## v) >> s->ps.sps->log2_min_pu_size))
                   ^
    libavcodec/hevc_mvs.c:204:14: note: in definition of macro 'TAB_MVF'
         tab_mvf[(y) * min_pu_width + x]
                  ^
    libavcodec/hevc_mvs.c:274:16: note: in expansion of macro 'TAB_MVF_PU'
         (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
                    ^
    libavcodec/hevc_mvs.c:683:24: note: in expansion of macro 'AVAILABLE'
         is_available_b0 =  AVAILABLE(cand_up_right, B0) &&
                            ^
    libavcodec/hevc_mvs.c:207:15: error: 'x0000000' undeclared (first use in this function)
         TAB_MVF(((x ## v) >> s->ps.sps->log2_min_pu_size),                     \
                   ^
    libavcodec/hevc_mvs.c:204:34: note: in definition of macro 'TAB_MVF'
         tab_mvf[(y) * min_pu_width + x]
                                      ^
    libavcodec/hevc_mvs.c:274:16: note: in expansion of macro 'TAB_MVF_PU'
         (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
                    ^
    libavcodec/hevc_mvs.c:683:24: note: in expansion of macro 'AVAILABLE'
         is_available_b0 =  AVAILABLE(cand_up_right, B0) &&
                            ^
    make: *** [libavcodec/hevc_mvs.o] Error 1
    

    解决:将libavcodec/hevc_mvs.c文件的变量B0改成b0,xB0改成xb0,yB0改成yb0

    问题三

    libavcodec/opus_pvq.c: In function 'quant_band_template':
    libavcodec/opus_pvq.c:498:9: error: expected identifier or '(' before numeric constant
         int B0 = blocks;
             ^
    libavcodec/opus_pvq.c:559:12: error: lvalue required as left operand of assignment
             B0 = blocks;
                ^
    make: *** [libavcodec/opus_pvq.o] Error 1
    

    解决:将libavcodec/opus_pvq.c文件的变量B0改成b0

    参考:https://www.jianshu.com/p/484db5ec733f

    相关文章

      网友评论

          本文标题:使用android-ndk-r17c构建ffmpeg 4.2.1

          本文链接:https://www.haomeiwen.com/subject/rnuywctx.html