• ffmpeg编译so


    1.第一个坑:/bin/bash^M: bad interpreter: No such file or directory

    shell脚本报错/bin/bash^M: bad interpreter: No such file or directory,通过查阅资料得知,shell脚本格式必须是unix才行,但我这个脚本是在windows上编写完成传到Linux服务器上的,所以一执行就报错

    windows环境下的文件是dos格式,即每行结尾以\r\n来标识,而linux下的文件是unix格式,行尾则以\n来标识

    查看文件是dos还是unix的格式的方法:

    1.cat -A filename,如果输出结果中行末是^M$,则是dos格式 ,如果行末只是$,则是unix格式。

    2.vim filename,编辑文件,执行“:set ff”,若执行结果为fileformat=dos则为dos格式,若执行结果为fileformat=unix则为unix格式。

    3.od -t x1 filename,以16进制查看文件,若输出结果中存在“0d 0a”则为dos格式,如果只有“0a”则为unix格式。其中“0d”即为回车符“\r”,“0a”即为换行符“\n”。

    文件格式转换:

    1.sed -i “s/\r//” filename 或sed -i “s/^M//” filename,直接将回车符替换为空字符串。

    2.vim filename,编辑文件,执行“: set ff=unix”,将文件设置为unix格式,然后执行“:wq”,保存退出。

    3.dos2unix filename或busybox dos2unix filename

    转换成unix格式就可以正常运行脚本了

     2.编译so

    脚本

    1. #!/bin/bash
    2. make clean
    3. #填写你具体的ndk解压目录 建议用相对路径
    4. export NDK=../android-ndk-r20b
    5. export SYSROOT=$NDK/platforms/android-28/arch-arm/
    6. export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
    7. export CPU=arm
    8. #编译后的文件会放置在 当前路径下的android/arm下
    9. export PREFIX=$(pwd)/android/$CPU
    10. export ADDI_CFLAGS="-marm"
    11. #./configure 即为ffmpeg 根目录下的可执行文件configure
    12. #你可以在ffmpeg根目录下使用./configure --hellp 查看 ./configure后可填入的参数。
    13. ./configure --target-os=linux \
    14. --prefix=$PREFIX --arch=arm \
    15. --disable-doc \
    16. --enable-shared \
    17. --disable-static \
    18. --disable-yasm \
    19. --disable-symver \
    20. --enable-gpl \
    21. --disable-ffmpeg \
    22. --disable-ffplay \
    23. --disable-ffprobe \
    24. --disable-ffserver \
    25. --disable-doc \
    26. --disable-symver \
    27. --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    28. --enable-cross-compile \
    29. --sysroot=$SYSROOT \
    30. --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    31. --extra-ldflags="$ADDI_CFLAGS" \
    32. $ADDITIONAL_CONFIGURE_FLAG
    33. make clean
    34. make
    35. make install

    编译成功会生成如下目录

     include是头文件  lib是so库

    遇到的问题

    1.编译FFMPEG时,出现了错误 nasm/yasm not found or too old. Use --disable-x86asm for a crippled build. 

    原因
    这是因为 FFMPEG为了提高编译速度,使用了汇编指令,如MMX和SSE等。如果系统中没有yasm指令的话,就会该错误。

    解决办法
    安装yasm。

    安装yasm
    Windows系统安装yasm
    如果是Windows系统, 从网上下载一个 yasm.exe 并安装在mingw/bin下面,重新编译,就不会出现该错误了。

    Linux系统安装yasm
    如果是Linux系统,则更简单,直接在终端输入 yum install yasm , 安装好后,重新编译就 OK了。

    除了使用yum安装yasm,还可以编译安装,如下:
    在http://www.tortall.net/projects/yasm/releases下面找到适合自己平台的yasm版本。然后进行安装。举例如下:

    1)下载:wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

    2)解压:tar zxvf yasm-1.3.0.tar.gz

    3)切换路径: cd yasm-1.3.0

    4)执行配置: ./configure

    5)编译:make

    6)安装:make install
     

    2.执行脚本报错 缺少文件

    1. root@realbom2-PowerEdge-R730xd:/lv1/wanglongjiang/ffmpeg/ffmpeg-6.0# ./build.sh
    2. Makefile:2: ffbuild/config.mak: No such file or directory
    3. Makefile:42: /tools/Makefile: No such file or directory
    4. Makefile:43: /ffbuild/common.mak: No such file or directory
    5. Makefile:113: /libavutil/Makefile: No such file or directory
    6. Makefile:113: /ffbuild/library.mak: No such file or directory
    7. Makefile:115: /fftools/Makefile: No such file or directory
    8. Makefile:116: /doc/Makefile: No such file or directory
    9. Makefile:117: /doc/examples/Makefile: No such file or directory
    10. Makefile:184: /tests/Makefile: No such file or directory
    11. make: *** No rule to make target '/tests/Makefile'. Stop.
    12. Unknown option "--disable-ffserver".
    13. See ./configure --help for available options.
    14. Makefile:2: ffbuild/config.mak: No such file or directory
    15. Makefile:42: /tools/Makefile: No such file or directory
    16. Makefile:43: /ffbuild/common.mak: No such file or directory
    17. Makefile:113: /libavutil/Makefile: No such file or directory
    18. Makefile:113: /ffbuild/library.mak: No such file or directory
    19. Makefile:115: /fftools/Makefile: No such file or directory
    20. Makefile:116: /doc/Makefile: No such file or directory
    21. Makefile:117: /doc/examples/Makefile: No such file or directory
    22. Makefile:184: /tests/Makefile: No such file or directory
    23. make: *** No rule to make target '/tests/Makefile'. Stop.
    24. Makefile:2: ffbuild/config.mak: No such file or directory
    25. Makefile:42: /tools/Makefile: No such file or directory
    26. Makefile:43: /ffbuild/common.mak: No such file or directory
    27. Makefile:113: /libavutil/Makefile: No such file or directory
    28. Makefile:113: /ffbuild/library.mak: No such file or directory
    29. Makefile:115: /fftools/Makefile: No such file or directory
    30. Makefile:116: /doc/Makefile: No such file or directory
    31. Makefile:117: /doc/examples/Makefile: No such file or directory
    32. Makefile:184: /tests/Makefile: No such file or directory
    33. make: *** No rule to make target '/tests/Makefile'. Stop.
    34. Makefile:2: ffbuild/config.mak: No such file or directory
    35. Makefile:42: /tools/Makefile: No such file or directory
    36. Makefile:43: /ffbuild/common.mak: No such file or directory
    37. Makefile:113: /libavutil/Makefile: No such file or directory
    38. Makefile:113: /ffbuild/library.mak: No such file or directory
    39. Makefile:115: /fftools/Makefile: No such file or directory
    40. Makefile:116: /doc/Makefile: No such file or directory
    41. Makefile:117: /doc/examples/Makefile: No such file or directory
    42. Makefile:184: /tests/Makefile: No such file or directory
    43. make: *** No rule to make target '/tests/Makefile'. Stop.

    解决方法:
    先不要执行make和make install,先在ffmpeg目录下执行./configure,该命令会自动生成缺少的文件

  • 相关阅读:
    IOT跨平台组件设计方案
    18.四数之和
    FANUC机器人用户自定义报警的具体配置方法详解
    疫情防控管理系统
    [附源码]JAVA毕业设计高校在线教师教学学术能力评价系统(系统+LW)
    Redis Key-Value数据库 【实战】
    Simple RPC - 02 通用高性能序列化和反序列化设计与实现
    Himall验证帮助类判断当前时间是否在指定的时间段内、判断一个ip是否在另一个ip内
    Centos中清除因程序异常终止,导致的残留的Cache/buff_drop_caches命令---linux工作笔记063
    如何理解dotplot
  • 原文地址:https://blog.csdn.net/xiaowang_lj/article/details/127915267