ubuntu 交叉编译 armv7_32 ffmpeg x264(已完成)
文章目錄
- 1、交叉編譯x264(x264要先編譯,因為到時編譯ffmpeg時要用到x264的頭文件和庫)
- 2、接著我們編譯ffmpeg
FFmpeg和X264的交叉編譯環境
arm linux交叉編譯x264 ffmpeg
ffmpeg與x264差異?
Linux下交叉編譯FFMPEG與X264庫:目標板友善之臂Tiny4412開發板_EXYNOS4412(ARMV7_32位)(這個還有直接用ffmpeg在arm下采集攝像頭數據生成MP4視頻的代碼呢!)
FFmpeg需要X264庫才能正常編碼x264,所以不知道我們arm攝像頭里是否缺少x264庫,所以我們先交叉編譯個x264進去看看?
1、交叉編譯x264(x264要先編譯,因為到時編譯ffmpeg時要用到x264的頭文件和庫)
我可以參照我之前交叉編譯netkit-ftp的方法
下載 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 messageStandard 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 RCFLAGSConfiguration 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 codeCross-compilation:--host=HOST build programs to run on HOST--cross-prefix=PREFIX use PREFIX for compilation tools--sysroot=SYSROOT root of cross-build treeExternal 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
繼續運行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: allYou 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 filtersStandard 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 pathsnot part of the dynamic linker search pathuse 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 libsand binaries will be under GPL [no]--enable-version3 upgrade (L)GPL to version 3 [no]--enable-nonfree allow use of nonfree code, the resulting libsand 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 buildDocumentation 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 pagesComponent 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 libavutilIndividual 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 filtersExternal library support:Using any of the following switches will allow FFmpeg to link to thecorresponding external library. All the components depending on that librarywill become enabled, if all their other dependencies are met and they are notexplicitly disabled. E.g. --enable-libopus will enable linking tolibopus and allow the libopus encoder to be built, unless it isspecifically 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 externallibraries must be explicitly enabled.//請注意,只有系統庫是自動檢測的。所有其他外部庫都必須顯式啟用。Also note that the following help text describes the purpose of the librariesthemselves, 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 supportif openssl, librtmp or gmp is not used [no]--enable-gmp enable gmp, needed for rtmp(t)e supportif openssl or librtmp is not used [no]--enable-gnutls enable gnutls, needed for https supportif 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 libdc1394and 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]--enable-libkvazaar enable HEVC encoding via libkvazaar [no]--enable-liblensfun enable lensfun lens correction [no]--enable-libmodplug enable ModPlug via libmodplug [no]--enable-libmp3lame enable MP3 encoding via libmp3lame [no]--enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]--enable-libopencv enable video filtering via libopencv [no]--enable-libopenh264 enable H.264 encoding via OpenH264 [no]--enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]--enable-libopenmpt enable decoding tracked files via libopenmpt [no]--enable-libopenvino enable OpenVINO as a DNN module backendfor DNN based filters like dnn_processing [no]--enable-libopus enable Opus de/encoding via libopus [no]--enable-libpulse enable Pulseaudio input via libpulse [no]--enable-librabbitmq enable RabbitMQ library [no]--enable-librav1e enable AV1 encoding via rav1e [no]--enable-librist enable RIST via librist [no]--enable-librsvg enable SVG rasterization via librsvg [no]--enable-librubberband enable rubberband needed for rubberband filter [no]--enable-librtmp enable RTMP[E] support via librtmp [no]--enable-libshine enable fixed-point MP3 encoding via libshine [no]--enable-libsmbclient enable Samba protocol via libsmbclient [no]--enable-libsnappy enable Snappy compression, needed for hap encoding [no]--enable-libsoxr enable Include libsoxr resampling [no]--enable-libspeex enable Speex de/encoding via libspeex [no]--enable-libsrt enable Haivision SRT protocol via libsrt [no]--enable-libssh enable SFTP protocol via libssh [no]--enable-libsvtav1 enable AV1 encoding via SVT [no]--enable-libtensorflow enable TensorFlow as a DNN module backendfor DNN based filters like sr [no]--enable-libtesseract enable Tesseract, needed for ocr filter [no]--enable-libtheora enable Theora encoding via libtheora [no]--enable-libtls enable LibreSSL (via libtls), needed for https supportif openssl, gnutls or mbedtls is not used [no]--enable-libtwolame enable MP2 encoding via libtwolame [no]--enable-libuavs3d enable AVS3 decoding via libuavs3d [no]--enable-libv4l2 enable libv4l2/v4l-utils [no]--enable-libvidstab enable video stabilization using vid.stab [no]--enable-libvmaf enable vmaf filter via libvmaf [no]--enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]--enable-libvorbis enable Vorbis en/decoding via libvorbis,native implementation exists [no]--enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]--enable-libwebp enable WebP encoding via libwebp [no]--enable-libx264 enable H.264 encoding via x264 [no] //通過x264啟用H.264編碼[否]--enable-libx265 enable HEVC encoding via x265 [no]--enable-libxavs enable AVS encoding via xavs [no]--enable-libxavs2 enable AVS2 encoding via xavs2 [no]--enable-libxcb enable X11 grabbing using XCB [autodetect]--enable-libxcb-shm enable X11 grabbing shm communication [autodetect]--enable-libxcb-xfixes enable X11 grabbing mouse rendering [autodetect]--enable-libxcb-shape enable X11 grabbing shape rendering [autodetect]--enable-libxvid enable Xvid encoding via xvidcore,native MPEG-4/Xvid encoder exists [no]--enable-libxml2 enable XML parsing using the C library libxml2, neededfor dash demuxing support [no]--enable-libzimg enable z.lib, needed for zscale filter [no]--enable-libzmq enable message passing via libzmq [no]--enable-libzvbi enable teletext support via libzvbi [no]--enable-lv2 enable LV2 audio filtering [no]--disable-lzma disable lzma [autodetect]--enable-decklink enable Blackmagic DeckLink I/O support [no]--enable-mbedtls enable mbedTLS, needed for https supportif openssl, gnutls or libtls is not used [no]--enable-mediacodec enable Android MediaCodec support [no]--enable-mediafoundation enable encoding via MediaFoundation [auto]--enable-libmysofa enable libmysofa, needed for sofalizer filter [no]--enable-openal enable OpenAL 1.1 capture support [no]--enable-opencl enable OpenCL processing [no]--enable-opengl enable OpenGL rendering [no]--enable-openssl enable openssl, needed for https supportif gnutls, libtls or mbedtls is not used [no]--enable-pocketsphinx enable PocketSphinx, needed for asr filter [no]--disable-sndio disable sndio support [autodetect]--disable-schannel disable SChannel SSP, needed for TLS support onWindows if openssl and gnutls are not used [autodetect]--disable-sdl2 disable sdl2 [autodetect]--disable-securetransport disable Secure Transport, needed for TLS supporton OSX if openssl and gnutls are not used [autodetect]--enable-vapoursynth enable VapourSynth demuxer [no]--enable-vulkan enable Vulkan code [no]--disable-xlib disable xlib [autodetect]--disable-zlib disable zlib [autodetect]The following libraries provide various hardware acceleration features:--disable-amf disable AMF video encoding code [autodetect]--disable-audiotoolbox disable Apple AudioToolbox code [autodetect]--enable-cuda-nvcc enable Nvidia CUDA compiler [no]--disable-cuda-llvm disable CUDA compilation using clang [autodetect]--disable-cuvid disable Nvidia CUVID support [autodetect]--disable-d3d11va disable Microsoft Direct3D 11 video acceleration code [autodetect]--disable-dxva2 disable Microsoft DirectX 9 video acceleration code [autodetect]--disable-ffnvcodec disable dynamically linked Nvidia code [autodetect]--enable-libdrm enable DRM code (Linux) [no]--enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no]--enable-libnpp enable Nvidia Performance Primitives-based code [no]--enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no]--disable-nvdec disable Nvidia video decoding acceleration (via hwaccel) [autodetect]--disable-nvenc disable Nvidia video encoding code [autodetect]--enable-omx enable OpenMAX IL code [no]--enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no]--enable-rkmpp enable Rockchip Media Process Platform code [no]--disable-v4l2-m2m disable V4L2 mem2mem code [autodetect]--disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect]--disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect]--disable-videotoolbox disable VideoToolbox code [autodetect]Toolchain options:--arch=ARCH select architecture [] //選擇架構--cpu=CPU select the minimum required CPU (affectsinstruction selection, may crash on older CPUs)--cross-prefix=PREFIX use PREFIX for compilation tools [] //為編譯工具使用前綴(就是讓它知道你的編譯工具鏈在哪)--progs-suffix=SUFFIX program name suffix []--enable-cross-compile assume a cross-compiler is used--sysroot=PATH root of cross-build tree--sysinclude=PATH location of cross-build system headers--target-os=OS compiler targets OS []--target-exec=CMD command to run executables on target--target-path=DIR path to view of build directory on target--target-samples=DIR path to samples directory on target--tempprefix=PATH force fixed dir/prefix instead of mktemp for checks--toolchain=NAME set tool defaults according to NAME(gcc-asan, clang-asan, gcc-msan, clang-msan,gcc-tsan, clang-tsan, gcc-usan, clang-usan,valgrind-massif, valgrind-memcheck,msvc, icl, gcov, llvm-cov, hardened)--nm=NM use nm tool NM [nm -g]--ar=AR use archive tool AR [ar]--as=AS use assembler AS []--ln_s=LN_S use symbolic link tool LN_S [ln -s -f]--strip=STRIP use strip tool STRIP [strip]--windres=WINDRES use windows resource compiler WINDRES [windres]--x86asmexe=EXE use nasm-compatible assembler EXE [nasm]--cc=CC use C compiler CC [gcc]--cxx=CXX use C compiler CXX [g++]--objcc=OCC use ObjC compiler OCC [gcc]--dep-cc=DEPCC use dependency generator DEPCC [gcc]--nvcc=NVCC use Nvidia CUDA compiler NVCC or clang []--ld=LD use linker LD []--pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [pkg-config]--pkg-config-flags=FLAGS pass additional flags to pkgconf []--ranlib=RANLIB use ranlib RANLIB [ranlib]--doxygen=DOXYGEN use DOXYGEN to generate API doc [doxygen]--host-cc=HOSTCC use host C compiler HOSTCC--host-cflags=HCFLAGS use HCFLAGS when compiling for host--host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host--host-ld=HOSTLD use host linker HOSTLD--host-ldflags=HLDFLAGS use HLDFLAGS when linking for host--host-extralibs=HLIBS use libs HLIBS when linking for host--host-os=OS compiler host OS [] //編譯器主機操作系統--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS []--extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS []--extra-objcflags=FLAGS add FLAGS to OBJCFLAGS []--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS []--extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS []--extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS []--extra-libs=ELIBS add ELIBS []--extra-version=STRING version string suffix []--optflags=OPTFLAGS override optimization-related compiler flags--nvccflags=NVCCFLAGS override nvcc flags []--build-suffix=SUFFIX library name suffix []--enable-pic build position-independent code //構建位置無關代碼(?)--enable-thumb compile for Thumb instruction set--enable-lto use link-time optimization--env="ENV=override" override the environment variablesAdvanced options (experts only):--malloc-prefix=PREFIX prefix malloc and related names with PREFIX--custom-allocator=NAME use a supported custom allocator--disable-symver disable symbol versioning--enable-hardcoded-tables use hardcoded tables instead of runtime generation--disable-safe-bitstream-readerdisable buffer boundary checking in bitreaders(faster, but may crash)--sws-max-filter-size=N the max filter size swscale uses [256]Optimization options (experts only):--disable-asm disable all assembly optimizations--disable-altivec disable AltiVec optimizations--disable-vsx disable VSX optimizations--disable-power8 disable POWER8 optimizations--disable-amd3dnow disable 3DNow! optimizations--disable-amd3dnowext disable 3DNow! extended optimizations--disable-mmx disable MMX optimizations--disable-mmxext disable MMXEXT optimizations--disable-sse disable SSE optimizations--disable-sse2 disable SSE2 optimizations--disable-sse3 disable SSE3 optimizations--disable-ssse3 disable SSSE3 optimizations--disable-sse4 disable SSE4 optimizations--disable-sse42 disable SSE4.2 optimizations--disable-avx disable AVX optimizations--disable-xop disable XOP optimizations--disable-fma3 disable FMA3 optimizations--disable-fma4 disable FMA4 optimizations--disable-avx2 disable AVX2 optimizations--disable-avx512 disable AVX-512 optimizations--disable-aesni disable AESNI optimizations--disable-armv5te disable armv5te optimizations--disable-armv6 disable armv6 optimizations--disable-armv6t2 disable armv6t2 optimizations--disable-vfp disable VFP optimizations--disable-neon disable NEON optimizations--disable-inline-asm disable use of inline assembly--disable-x86asm disable use of standalone x86 assembly--disable-mipsdsp disable MIPS DSP ASE R1 optimizations--disable-mipsdspr2 disable MIPS DSP ASE R2 optimizations--disable-msa disable MSA optimizations--disable-msa2 disable MSA2 optimizations--disable-mipsfpu disable floating point MIPS optimizations--disable-mmi disable Loongson SIMD optimizations--disable-fast-unaligned consider unaligned accesses slowDeveloper options (useful when working on FFmpeg itself):--disable-debug disable debugging symbols--enable-debug=LEVEL set the debug level []--disable-optimizations disable compiler optimizations--enable-extra-warnings enable more compiler warnings--disable-stripping disable stripping of executables and shared libraries--assert-level=level 0(default), 1 or 2, amount of assertion testing,2 causes a slowdown at runtime.--enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data--valgrind=VALGRIND run "make fate" tests through valgrind to detect memoryleaks and errors, using the specified valgrind binary.Cannot be combined with --target-exec--enable-ftrapv Trap arithmetic overflows--samples=PATH location of test samples for FATE, if not set use$FATE_SAMPLES at make invocation time.--enable-neon-clobber-test check NEON registers for clobbering (should beused only for debugging purposes)--enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;should be used only for debugging purposes)--enable-random randomly enable/disable components--disable-random--enable-random=LIST randomly enable/disable specific components or--disable-random=LIST component groups. LIST is a comma-separated listof NAME[:PROB] entries where NAME is a component(group) and PROB the probability associated withNAME (default 0.5).--random-seed=VALUE seed value for --enable/disable-random--disable-valgrind-backtrace do not print a backtrace under Valgrind(only applies to --disable-optimizations builds)--enable-ossfuzz Enable building fuzzer tool--libfuzzer=PATH path to libfuzzer--ignore-tests=TESTS comma-separated list (without "fate-" prefixin the name) of tests whose result is ignored--enable-linux-perf enable Linux Performance Monitor API--disable-large-tests disable tests that use a large amount of memoryNOTE: Object files are built at the place where configure is launched. [yg@ubuntu /arnold_test/20220105_crossCompile_x264_ffmpeg/ffmpeg/ffmpeg-4.4]13$然后撰寫arnold_run.sh,同時新建文件夾arnold_build,在arnold_run.sh中填入:
一開始的配置(棄用)
arnold_run.sh
新配置(參考:Linux下交叉編譯FFMPEG與X264庫:目標板友善之臂Tiny4412開發板_EXYNOS4412(ARMV7_32位))
(注意其中鏈接x264頭文件和庫目錄,,,其實到時ffmpeg運行的時候也得把x264的動態庫文件給弄進去,不然ffmpeg找不到x264的動態庫文件也會報錯)
arnold_run.sh
#!/bin/sh./configure \ --enable-shared \ --enable-static \ --prefix=/arnold_test/20220105_crossCompile_x264_ffmpeg/ffmpeg/ffmpeg-4.4/arnold_build \ --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- \ --arch=arm \ --target-os=linux \ --enable-gpl \ --extra-cflags=-I/arnold_test/20220105_crossCompile_x264_ffmpeg/x264/arnold_build/include \ --extra-ldflags=-L/arnold_test/20220105_crossCompile_x264_ffmpeg/x264/arnold_build/lib \ --enable-ffmpeg \ --enable-libx264然后make && make install,一切順利,就是最后出來的lib文件有點大,總共200多兆
然后我們將ffmpeg二進制文件拷貝到arm的/opt/ffmpeg目錄下,執行./ffmpeg -h發現提示缺少庫文件,然后我們創建lib文件夾,并將它添加到環境變量的搜索庫目錄
(提示缺少庫文件)
[root@RV1126_RV1109:/opt/ffmpeg]# ./ffmpeg -h ./ffmpeg: error while loading shared libraries: libpostproc.so.55: cannot open shared object file: No such file or directory [root@RV1126_RV1109:/opt/ffmpeg]#(創建lib目錄)
(添加環境變量庫搜索路徑,參考:linux armv7_32環境變量配置(LD_LIBRARY_PATH 庫搜索路徑))
(執行source /etc/profile讓環境變量生效)
然后運行提示缺哪個庫文件,就用xftp從我們交叉編譯生成的lib目錄里拷貝哪個進去
對了,那個前面編譯生成的libx264的庫文件也要拷進去(我也沒管缺哪個,靜態庫動態庫,三個都拷進去了)
還沒拷貝完呢,我們的命令就能運行了
[root@RV1126_RV1109:/opt/ffmpeg]# ./ffmpeg -i 1e1fee9790f26fa3_202214225310.h264 -vcodec copy -f mp4 test.mp4
...libavutil 56. 70.100 / 56. 70.100libavcodec 58.134.100 / 58.134.100libavformat 58. 76.100 / 58. 76.100libavdevice 58. 13.100 / 58. 5.100libavfilter 7.110.100 / 7.110.100libswscale 5. 9.100 / 5. 9.100libswresample 3. 9.100 / 3. 3.100libpostproc 55. 9.100 / 55. 9.100 Input #0, h264, from '1e1fee9790f26fa3_202214225310.h264':Duration: N/A, bitrate: N/AStream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc File 'test.mp4' already exists. Overwrite? [y/N] y Output #0, mp4, to 'test.mp4':Metadata:encoder : Lavf58.76.100Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, q=2-31, 25 fps, 25 tbr, 1200k tbn, 1200k tbc Stream mapping:Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help [mp4 @ 0x60170] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly frame= 150 fps=0.0 q=-1.0 Lsize= 1451kB time=00:00:05.96 bitrate=1994.0kbits/s speed= 289x video:1449kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.098579% [root@RV1126_RV1109:/opt/ffmpeg]#然后轉換后的視頻也能方到瀏覽器運行了,沒有編碼問題
總結
以上是生活随笔為你收集整理的ubuntu 交叉编译 armv7_32 ffmpeg x264(已完成)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ffmpeg与x264有什么区别?
- 下一篇: ubuntu18.04安装pycharm