ubuntu 交叉编译 armv7_32 ffmpeg x264(已完成)
Posted Dontla
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu 交叉编译 armv7_32 ffmpeg x264(已完成)相关的知识,希望对你有一定的参考价值。
Linux下交叉编译FFMPEG与X264库:目标板友善之臂Tiny4412开发板_EXYNOS4412(ARMV7_32位)(这个还有直接用ffmpeg在arm下采集摄像头数据生成MP4视频的代码呢!)
FFmpeg需要X264库才能正常编码x264,所以不知道我们arm摄像头里是否缺少x264库,所以我们先交叉编译个x264进去看看?
1、交叉编译x264(x264要先编译,因为到时编译ffmpeg时要用到x264的头文件和库)
下载 x264:git clone VideoLAN / x264
拷贝到ubuntu虚拟机中,在里面运行configure --help
查看make
配置指令,发现出现/bin/bash^M: bad interpreter: No such file or directory
,用linux arm 运行 shell .sh 脚本文件报错:/bin/bash^M: bad interpreter: No such file or directory(dos2unix )
方法解决一下就好了
查看编译帮助
[root@ubuntu /arnold_test/20220105_crossCompile_x264_ffmpeg/x264]1# ./configure --help
Usage: ./configure [options]
Help:
-h, --help print this message
Standard options:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
--bindir=DIR install binaries in DIR [EPREFIX/bin]
--libdir=DIR install libs in DIR [EPREFIX/lib]
--includedir=DIR install includes in DIR [PREFIX/include]
--extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
--extra-rcflags=ERCFLAGS add ERCFLAGS to RCFLAGS
Configuration options:
--disable-cli disable cli //取消命令行(command line)
--system-libx264 use system libx264 instead of internal
--enable-shared build shared library
--enable-static build static library
--disable-bashcompletion disable installation of bash-completion script
--enable-bashcompletion force installation of bash-completion script
--bashcompletionsdir=DIR install bash-completion script in DIR [auto]
--disable-opencl disable OpenCL features
--disable-gpl disable GPL-only features
--disable-thread disable multithreaded encoding
--disable-win32thread disable win32threads (windows only)
--disable-interlaced disable interlaced encoding support
--bit-depth=BIT_DEPTH set output bit depth (8, 10, all) [all]
--chroma-format=FORMAT output chroma format (400, 420, 422, 444, all) [all]
Advanced options:
--disable-asm disable platform-specific assembly optimizations
--enable-lto enable link-time optimization
--enable-debug add -g
--enable-gprof add -pg
--enable-strip add -s
--enable-pic build position-independent code
Cross-compilation:
--host=HOST build programs to run on HOST
--cross-prefix=PREFIX use PREFIX for compilation tools
--sysroot=SYSROOT root of cross-build tree
External library support:
--disable-avs disable avisynth support
--disable-swscale disable swscale support
--disable-lavf disable libavformat support
--disable-ffms disable ffmpegsource support
--disable-gpac disable gpac support
--disable-lsmash disable lsmash support
[root@ubuntu /arnold_test/20220105_crossCompile_x264_ffmpeg/x264]2#
新建arnold_run.sh
,
touch arnold_run.sh
并在里面键入:
#!/bin/sh
./configure --prefix=/arnold_test/20220105_crossCompile_x264_ffmpeg/x264/arnold_build --enable-shared --enable-static --host=arm-linux --cross-prefix=arm-linux-gnueabihf-gcc --disable-opencl --enable-pic --disable-asm
虽说我已经配置了交叉编译器的环境变量,但还是跟上次编译netkit-ftp一样,报了找不到编译器的错误:
参考解决方法:KYSL laoyuan 发来交叉编译后的ftp仓库 源码分析 在arm摄像头下用法分析(数据服务器ip、登录用户及密码)ftp(netkit-ftp)客户端交叉编译(arm移植ftp)
根据上面方法还是没解决,还是报No working C compiler found.
但是因为laoyuan直接在网上下了个别人编译好的,所以我就不自己编译了。。。先看看他那个能不能正常用吧。。
完全不能正常用啊,运行ffmpeg提示找不到ffmpeg,GAN!
然后我自己又在网上花了三块钱下了个,也有问题,报错还古里八怪的
还是重回编译正道吧!
重新编译:
参考文章:windows 编译 x264 报错 No working C compiler found 处理方法
根据文中指示,我们查看config.log
文件
哎呦我去,,一看就看明白了
修改arnold_run.sh
,把gnueabihf-
后面的gcc
删掉
arnold_run.sh
#!/bin/sh
./configure --prefix=/arnold_test/20220105_crossCompile_x264_ffmpeg/x264/arnold_build --enable-shared --enable-static --cross-prefix=arm-linux-gnueabihf- --host=arm-linux --disable-opencl --enable-pic --disable-asm
继续运行arnold_run.sh
,还是不行,报错:
invalid -march= option: `armv7-a'
解决不了啊。。。
能解决了,换上laoyuan给的交叉编译器,参考:KYSL 我们瑞芯微的交叉编译工具链位置
主要laoyuan说之前的交叉编译器给我搞坏了。。。
然后arnold_run.sh
改成:
#!/bin/sh
./configure --prefix=/arnold_test/20220105_crossCompile_x264_ffmpeg/x264/arnold_build --enable-shared --enable-static --cross-prefix=/home/yg/rv/sdk/rv1.8/rv1126_rv1109/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --host=arm-linux --disable-opencl --enable-pic --disable-asm
执行:
[root@ubuntu /arnold_test/20220105_crossCompile_x264_ffmpeg/x264]10# ./arnold_run.sh
platform: ARM
byte order: little-endian
system: LINUX
cli: yes
libx264: internal
shared: yes
static: yes
bashcompletion: no
asm: no
interlaced: yes
avs: avxsynth
lavf: no
ffms: no
mp4: no
gpl: yes
thread: posix
opencl: no
filters: crop select_every
lto: no
debug: no
gprof: no
strip: no
PIC: yes
bit depth: all
chroma format: all
You can run 'make' or 'make fprofiled' now.
[root@ubuntu /arnold_test/20220105_crossCompile_x264_ffmpeg/x264]11#
然后执行这个version.sh
,不然make
会提示x264.c:506:21: error: ‘X264_VERSION’ undeclared
然后执行make
和make install
,一切顺利
执行完make install
后,设置的arnold_build
中也出现了bin
、include
、lib
三个文件夹,眼前瞬间一亮,有种感觉全身经脉被打通的快感!
2、接着我们编译ffmpeg
搁这下:https://launchpad.net/ubuntu/+search?text=ffmpeg
下这个版本: 7:4.4-6ubuntu5
,这个看起来顺眼一点
下这个:ffmpeg_4.4.orig.tar.xz
下载好后拷贝到ubuntu里解压:
老样子,进去先执行./configure --help
查看编译配置帮助
[yg@ubuntu /arnold_test/20220105_crossCompile_x264_ffmpeg/ffmpeg/ffmpeg-4.4]7$ ./configure --help
配置帮助太长就不看了
还是要看下的,不看找不着北了。。。。执行./configure --help
[yg@ubuntu /arnold_test/20220105_crossCompile_x264_ffmpeg/ffmpeg/ffmpeg-4.4]12$ ./configure --help
tput: unknown terminal "xterm-256color"
tput: unknown terminal "xterm-256color"
Usage: configure [options]
Options: [defaults in brackets after descriptions] //描述后括号中的默认值
Help options:
--help print this message
--quiet Suppress showing informative output //抑制显示信息输出
--list-decoders show all available decoders
--list-encoders show all available encoders
--list-hwaccels show all available hardware accelerators
--list-demuxers show all available demuxers
--list-muxers show all available muxers //显示所有可用的多路复用器(封装器)
--list-parsers show all available parsers //解析器
--list-protocols show all available protocols //协议
--list-bsfs show all available bitstream filters //显示所有可用的位流筛选器
--list-indevs show all available input devices
--list-outdevs show all available output devices
--list-filters show all available filters
Standard options: //不是可选的,应该是默认都有的
--logfile=FILE log tests and output to FILE [ffbuild/config.log] //记录测试并输出到文件(默认)[ffbuild/config.log]
--disable-logging do not log configure debug information //不要记录配置调试信息
--fatal-warnings fail if any configure warning is generated //如果生成任何配置警告,则失败
--prefix=PREFIX install in PREFIX [/usr/local] //以前缀安装(默认)[/usr/local]
--bindir=DIR install binaries in DIR [PREFIX/bin] //在目录[PREFIX/bin]中安装二进制文件(可执行文件)
--datadir=DIR install data files in DIR [PREFIX/share/ffmpeg] //在目录[PREFIX/share/ffmpeg]中安装数据文件
--docdir=DIR install documentation in DIR [PREFIX/share/doc/ffmpeg]
--libdir=DIR install libs in DIR [PREFIX/lib]
--shlibdir=DIR install shared libs in DIR [LIBDIR] //动态库(sh = share)
--incdir=DIR install includes in DIR [PREFIX/include] //头文件(inc = include)
--mandir=DIR install man page in DIR [PREFIX/share/man]
--pkgconfigdir=DIR install pkg-config files in DIR [LIBDIR/pkgconfig]
--enable-rpath use rpath to allow installing libraries in paths
not part of the dynamic linker search path
use rpath when linking programs (USE WITH CARE) //不懂
--install-name-dir=DIR Darwin directory name for installed targets //不懂
Licensing options:
--enable-gpl allow use of GPL code, the resulting libs
and binaries will be under GPL [no]
--enable-version3 upgrade (L)GPL to version 3 [no]
--enable-nonfree allow use of nonfree code, the resulting libs
and binaries will be unredistributable [no] //如果允许使用非自由代码,则生成的库和二进制文件将不可分发[no]
Configuration options:
--disable-static do not build static libraries [no]
--enable-shared build shared libraries [no]
--enable-small optimize for size instead of speed //优化尺寸而不是速度
--disable-runtime-cpudetect disable detecting CPU capabilities at runtime (smaller binary) //禁用运行时检测CPU功能(较小的二进制文件)
--enable-gray enable full grayscale support (slower color) //启用全灰度支持(较慢的颜色)
--disable-swscale-alpha disable alpha channel support in swscale //禁用swscale中的alpha通道支持
--disable-all disable building components, libraries and programs
--disable-autodetect disable automatically detected external libraries [no]
Program options:
--disable-programs do not build command line programs
--disable-ffmpeg disable ffmpeg build
--disable-ffplay disable ffplay build
--disable-ffprobe disable ffprobe build
Documentation options:
--disable-doc do not build documentation
--disable-htmlpages do not build HTML documentation pages
--disable-manpages do not build man documentation pages
--disable-podpages do not build POD documentation pages
--disable-txtpages do not build text documentation pages
Component options:
--disable-avdevice disable libavdevice build
--disable-avcodec disable libavcodec build
--disable-avformat disable libavformat build
--disable-swresample disable libswresample build
--disable-swscale disable libswscale build
--disable-postproc disable libpostproc build
--disable-avfilter disable libavfilter build
--enable-avresample enable libavresample build (deprecated) [no]
--disable-pthreads disable pthreads [autodetect]
--disable-w32threads disable Win32 threads [autodetect]
--disable-os2threads disable OS/2 threads [autodetect]
--disable-network disable network support [no]
--disable-dct disable DCT code
--disable-dwt disable DWT code
--disable-error-resilience disable error resilience code
--disable-lsp disable LSP code
--disable-lzo disable LZO decoder code
--disable-mdct disable MDCT code
--disable-rdft disable RDFT code
--disable-fft disable FFT code
--disable-faan disable floating point AAN (I)DCT code
--disable-pixelutils disable pixel utils in libavutil
Individual component options:
--disable-everything disable all components listed below
--disable-encoder=NAME disable encoder NAME
--enable-encoder=NAME enable encoder NAME
--disable-encoders disable all encoders
--disable-decoder=NAME disable decoder NAME
--enable-decoder=NAME enable decoder NAME
--disable-decoders disable all decoders
--disable-hwaccel=NAME disable hwaccel NAME
--enable-hwaccel=NAME enable hwaccel NAME
--disable-hwaccels disable all hwaccels
--disable-muxer=NAME disable muxer NAME
--enable-muxer=NAME enable muxer NAME
--disable-muxers disable all muxers
--disable-demuxer=NAME disable demuxer NAME
--enable-demuxer=NAME enable demuxer NAME
--disable-demuxers disable all demuxers
--enable-parser=NAME enable parser NAME
--disable-parser=NAME disable parser NAME
--disable-parsers disable all parsers
--enable-bsf=NAME enable bitstream filter NAME
--disable-bsf=NAME disable bitstream filter NAME
--disable-bsfs disable all bitstream filters
--enable-protocol=NAME enable protocol NAME
--disable-protocol=NAME disable protocol NAME
--disable-protocols disable all protocols
--enable-indev=NAME enable input device NAME
--disable-indev=NAME disable input device NAME
--disable-indevs disable input devices
--enable-outdev=NAME enable output device NAME
--disable-outdev=NAME disable output device NAME
--disable-outdevs disable output devices
--disable-devices disable all devices
--enable-filter=NAME enable filter NAME
--disable-filter=NAME disable filter NAME
--disable-filters disable all filters
External library support:
Using any of the following switches will allow FFmpeg to link to the
corresponding external library. All the components depending on that library
will become enabled, if all their other dependencies are met and they are not
explicitly disabled. E.g. --enable-libopus will enable linking to
libopus and allow the libopus encoder to be built, unless it is
specifically disabled with --disable-encoder=libopus.
//使用以下任何开关将允许FFmpeg链接到相应的外部库。如果满足所有其他依赖项且未明确禁用,则依赖于该库的所有组件都将启用。例如--enable libopus将启用到libopus的链接并允许构建libopus编码器,除非使用--disable encoder=libopus专门禁用它。
Note that only the system libraries are auto-detected. All the other external
libraries must be explicitly enabled.
//请注意,只有系统库是自动检测的。所有其他外部库都必须显式启用。
Also note that the following help text describes the purpose of the libraries
themselves, not all their features will necessarily be usable by FFmpeg.
//还请注意,以下帮助文本描述了库本身的用途,但FFmpeg不一定能使用它们的所有功能。
--disable-alsa disable ALSA support [autodetect]
--disable-appkit disable Apple AppKit framework [autodetect]
--disable-avfoundation disable Apple AVFoundation framework [autodetect]
--enable-avisynth enable reading of AviSynth script files [no]
--disable-bzlib disable bzlib [autodetect]
--disable-coreimage disable Apple CoreImage framework [autodetect]
--enable-chromaprint enable audio fingerprinting with chromaprint [no]
--enable-frei0r enable frei0r video filtering [no]
--enable-gcrypt enable gcrypt, needed for rtmp(t)e support
if openssl, librtmp or gmp is not used [no]
--enable-gmp enable gmp, needed for rtmp(t)e support
if openssl or librtmp is not used [no]
--enable-gnutls enable gnutls, needed for https support
if openssl, libtls or mbedtls is not used [no]
--disable-iconv disable iconv [autodetect]
--enable-jni enable JNI support [no]
--enable-ladspa enable LADSPA audio filtering [no]
--enable-libaom enable AV1 video encoding/decoding via libaom [no]
--enable-libaribb24 enable ARIB text and caption decoding via libaribb24 [no]
--enable-libass enable libass subtitles rendering,
needed for subtitles and ass filter [no]
--enable-libbluray enable BluRay reading using libbluray [no]
--enable-libbs2b enable bs2b DSP library [no]
--enable-libcaca enable textual display using libcaca [no]
--enable-libcelt enable CELT decoding via libcelt [no]
--enable-libcdio enable audio CD grabbing with libcdio [no]
--enable-libcodec2 enable codec2 en/decoding using libcodec2 [no]
--enable-libdav1d enable AV1 decoding via libdav1d [no]
--enable-libdavs2 enable AVS2 decoding via libdavs2 [no]
--enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
--enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no]
--enable-libflite enable flite (voice synthesis) support via libflite [no]
--enable-libfontconfig enable libfontconfig, useful for drawtext filter [no]
--enable-libfreetype enable libfreetype, needed for drawtext filter [no]
--enable-libfribidi enable libfribidi, improves drawtext filter [no]
--enable-libglslang enable GLSL->SPIRV compilation via libglslang [no]
--enable-libgme enable Game Music Emu via libgme [no]
--enable-libgsm enable GSM de/encoding via libgsm [no]
--enable-libiec61883 enable iec61883 via libiec61883 [no]
--enable-libilbc enable iLBC de/encoding via libilbc [no]
--enable-libjack enable JACK audio sound server [no]
--enable-libklvanc enable Kernel Labs VANC processing [no]
--以上是关于ubuntu 交叉编译 armv7_32 ffmpeg x264(已完成)的主要内容,如果未能解决你的问题,请参考以下文章
适用于 iOS 的 leptonica 1.69 交叉编译(armv7、armv7s 和 arm64)
conan入门(十七):支持android NDK (armv7,armv8,x86,x86_64)交叉编译的统一profile jinja2模板