嵌入式平台交叉编译FFmpeg 6.1.1 动态库 实现rtsp解码

官方介绍

About FFmpeg

 

FFmpeg是一个领先的多媒体框架,能够解码、编码、转码、复用、解复用、流媒体传输、过滤和播放几乎所有由人类和机器创造的内容。它支持最不为人知的古老格式,直到最前沿的格式。无论这些格式是由一些标准委员会、社区还是公司设计的,FFmpeg都能处理。
此外,FFmpeg也具有高度的可移植性。它在Linux、Mac OS X、Microsoft Windows、BSDs、Solaris等各种操作系统上,以及各种构建环境、机器架构和配置下,都能成功编译、运行并通过我们的测试基础设施FATE。
FFmpeg的强大功能和灵活性使它成为处理多媒体内容的理想工具,无论是在个人电脑上还是在大型服务器上。它的广泛应用和强大的社区支持意味着你可以找到解决几乎任何问题的资源和帮助。

下载最新的源码包

图片[1]-嵌入式平台交叉编译FFmpeg 6.1.1 动态库 实现rtsp解码-天煜博客

前往官网下载最新的源码包并上传到Ubuntu编译机器上,。默认情况下,点击”Download Source Code”按钮会下载tar.xz格式的压缩包。为了获取更多版本选择,我点击了按钮下方的”More releases”。在这里不仅有不同版本号的源码包可供下载,还有不同的压缩方式可供选择,最终我选择了gzip格式的最新版本FFmpeg 6.1.1进行下载。

图片[2]-嵌入式平台交叉编译FFmpeg 6.1.1 动态库 实现rtsp解码-天煜博客

编译前的配置

使用tar解压后可以看到源码包里的目录

#查看configure的帮助 配置编译选项 ./configure –help

├── Changelog               # 记录项目的更新和变更历史
├── compat                  # 兼容性相关的代码
├── configure               # 用于配置项目的脚本
├── CONTRIBUTING.md         # 贡献指南,说明如何参与项目的贡献
├── COPYING.GPLv2           # GPLv2 版本的软件许可证
├── COPYING.GPLv3           # GPLv3 版本的软件许可证
├── COPYING.LGPLv2.1        # LGPLv2.1 版本的软件许可证
├── COPYING.LGPLv3          # LGPLv3 版本的软件许可证
├── CREDITS                 # 致谢,列出项目的贡献者
├── doc                     # 文档相关的目录
├── ffbuild                 # 用于构建的脚本和配置
├── fftools                 # 各种工具的源代码
├── INSTALL.md              # 安装说明
├── libavcodec              # 音视频编解码库的源代码
├── libavdevice             # 外部设备支持库的源代码
├── libavfilter             # 音视频过滤器库的源代码
├── libavformat             # 音视频封装格式处理库的源代码
├── libavutil               # 包含各种工具函数的库的源代码
├── libpostproc             # 后处理库的源代码
├── libswresample           # 音频采样格式转换库的源代码
├── libswscale              # 视频图像格式转换库的源代码
├── LICENSE.md              # 项目的许可证信息
├── MAINTAINERS             # 维护者列表,指定项目的维护人员
├── Makefile                # 项目的主要 Makefile
├── presets                 # 预设配置文件的目录
├── README.md               # 项目的主页和简要说明
├── RELEASE                 # 发布相关的信息
├── RELEASE_NOTES           # 发布说明,记录每个版本的变更
├── tests                   # 测试相关的代码和数据
├── tools                   # 各种辅助工具的源代码
└── VERSION                 # 项目的版本号信息

#configure的完整配置
./configure --help
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]
  --disable-logging        do not log configure debug information
  --fatal-warnings         fail if any configure warning is generated
  --prefix=PREFIX          install in PREFIX [/usr/local]
  --bindir=DIR             install binaries in DIR [PREFIX/bin]
  --datadir=DIR            install data files in DIR [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]
  --incdir=DIR             install includes in DIR [PREFIX/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]

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)
  --enable-gray            enable full grayscale support (slower color)
  --disable-swscale-alpha  disable alpha channel support in swscale
  --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
  --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-dwt            disable DWT code
  --disable-error-resilience disable error resilience code
  --disable-lsp            disable LSP 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.

  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.

  --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-lcms2           enable ICC profile support via LittleCMS 2 [no]
  --enable-libaom          enable AV1 video encoding/decoding via libaom [no]
  --enable-libaribb24      enable ARIB text and caption decoding via libaribb24 [no]
  --enable-libaribcaption  enable ARIB text and caption decoding via libaribcaption [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-libharfbuzz     enable libharfbuzz, needed for 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-libjxl          enable JPEG XL de/encoding via libjxl [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 backend
                           for DNN based filters like dnn_processing [no]
  --enable-libopus         enable Opus de/encoding via libopus [no]
  --enable-libplacebo      enable libplacebo library [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-libshaderc      enable GLSL->SPIRV compilation via libshaderc [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 backend
                           for 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 support
                           if 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]
  --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, needed
                           for dash and imf 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 support
                           if openssl, gnutls or libtls is not used [no]
  --enable-mediacodec      enable Android MediaCodec support [no]
  --enable-mediafoundation enable encoding via MediaFoundation [auto]
  --disable-metal          disable Apple Metal framework [autodetect]
  --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 support
                           if 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 on
                           Windows if openssl and gnutls are not used [autodetect]
  --disable-sdl2           disable sdl2 [autodetect]
  --disable-securetransport disable Secure Transport, needed for TLS support
                           on OSX if openssl and gnutls are not used [autodetect]
  --enable-vapoursynth     enable VapourSynth demuxer [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-libvpl          enable Intel oneVPL code via libvpl if libmfx is not used [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]
  --disable-vulkan         disable Vulkan code [autodetect]

Toolchain options:
  --arch=ARCH              select architecture []
  --cpu=CPU                select the minimum required CPU (affects
                           instruction 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 []
  --metalcc=METALCC        use metal compiler METALCC [xcrun -sdk macosx metal]
  --metallib=METALLIB      use metal linker METALLIB [xcrun -sdk macosx metallib]
  --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[=arg]       use link-time optimization
  --env="ENV=override"     override the environment variables

Advanced 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-reader
                           disable 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-avx512icl      disable AVX-512ICL 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-dotprod        disable DOTPROD optimizations
  --disable-i8mm           disable I8MM 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-mipsfpu        disable floating point MIPS optimizations
  --disable-mmi            disable Loongson MMI optimizations
  --disable-lsx            disable Loongson LSX optimizations
  --disable-lasx           disable Loongson LASX optimizations
  --disable-rvv            disable RISC-V Vector optimizations
  --disable-fast-unaligned consider unaligned accesses slow

Developer 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 memory
                           leaks 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 be
                           used 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 list
                           of NAME[:PROB] entries where NAME is a component
                           (group) and PROB the probability associated with
                           NAME (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-" prefix
                           in the name) of tests whose result is ignored
  --enable-linux-perf      enable Linux Performance Monitor API
  --enable-macos-kperf     enable macOS kperf (private) API
  --disable-large-tests    disable tests that use a large amount of memory
  --disable-ptx-compression don't compress CUDA PTX code even when possible

NOTE: Object files are built at the place where configure is launched.

交叉编译选项

我的编译目标:

    • 交叉编译到Arm Linux上运行

    • 编译成so动态库 供C语言调用

    • 实现RTSP解码

参考configure –help内容可以得出来configure的命令

#配置命令
./configure --prefix=/home/user/work/ffmpeg-6.1.1/install  --disable-programs --disable-static --enable-shared  --enable-cross-compile --cross-prefix=arm-linux-gnueabihf- --target-os=linux --arch=arm 

#命令解析
--prefix=/home/user/work/ffmpeg-6.1.1/install:指定安装目录,即生成的可执行文件和库文件将安装到该目录下。

--disable-programs:禁用编译 FFmpeg 自带的一些程序,这些程序一般用于演示和测试。

--disable-static:禁用静态库的生成,只生成共享库(动态链接库)。

--enable-shared:启用共享库的生成,即生成动态链接库。

--enable-cross-compile:启用交叉编译支持,表示将在非本机平台上进行编译。

--cross-prefix=arm-linux-gnueabihf-:指定交叉编译工具链的前缀,用于生成适用于 ARM 架构的二进制文件。

--target-os=linux:指定目标操作系统为 Linux。

--arch=arm:指定目标架构为 ARM。

这些选项的组合说明了你正在配置 FFmpeg 以在 ARM 架构的 Linux 系统上进行交叉编译。生成的二进制文件和库将会安装到指定的目录 /home/user/work/ffmpeg-6.1.1/install 中。


# 2024.06.13补充
在交叉编译RK3588平台的时候报了一些错误 类似下面这样:
/tmp/ccag2k7f.s: Assembler messages:
/tmp/ccag2k7f.s:1771: Error: unknown mnemonic `itt' -- `itt gt'
/tmp/ccag2k7f.s:1772: Error: unknown mnemonic `movgt' -- `movgt x10,x1'
/tmp/ccag2k7f.s:1773: Error: unknown mnemonic `movgt' -- `movgt x1,x2'
/tmp/ccag2k7f.s:1775: Error: unknown mnemonic `it' -- `it le'
/tmp/ccag2k7f.s:1776: Error: unknown mnemonic `movle' -- `movle x1,x3'
/tmp/ccag2k7f.s:1778: Error: unknown mnemonic `it' -- `it gt'
/tmp/ccag2k7f.s:1779: Error: unknown mnemonic `movgt' -- `movgt x10,x1'
/tmp/ccag2k7f.s:1797: Error: unknown mnemonic `itt' -- `itt gt'

可以通过配置--disable-asm选项解决

编译与安装

#编译与安装
make -j16 && make install

#编译完成后 会将文件存放在prefix目录下
install
├── include
│   ├── libavcodec
│   │   ├── ac3_parser.h
│   │   ├── adts_parser.h
│   │   ├── avcodec.h
│   │   ├── avdct.h
│   │   ├── avfft.h
│   │   ├── bsf.h
│   │   ├── codec_desc.h
│   │   ├── codec.h
│   │   ├── codec_id.h
│   │   ├── codec_par.h
│   │   ├── d3d11va.h
│   │   ├── defs.h
│   │   ├── dirac.h
│   │   ├── dv_profile.h
│   │   ├── dxva2.h
│   │   ├── jni.h
│   │   ├── mediacodec.h
│   │   ├── packet.h
│   │   ├── qsv.h
│   │   ├── vdpau.h
│   │   ├── version.h
│   │   ├── version_major.h
│   │   ├── videotoolbox.h
│   │   ├── vorbis_parser.h
│   │   └── xvmc.h
│   ├── libavdevice
│   │   ├── avdevice.h
│   │   ├── version.h
│   │   └── version_major.h
│   ├── libavfilter
│   │   ├── avfilter.h
│   │   ├── buffersink.h
│   │   ├── buffersrc.h
│   │   ├── version.h
│   │   └── version_major.h
│   ├── libavformat
│   │   ├── avformat.h
│   │   ├── avio.h
│   │   ├── version.h
│   │   └── version_major.h
│   ├── libavutil
│   │   ├── adler32.h
│   │   ├── aes_ctr.h
│   │   ├── aes.h
│   │   ├── ambient_viewing_environment.h
│   │   ├── attributes.h
│   │   ├── audio_fifo.h
│   │   ├── avassert.h
│   │   ├── avconfig.h
│   │   ├── avstring.h
│   │   ├── avutil.h
│   │   ├── base64.h
│   │   ├── blowfish.h
│   │   ├── bprint.h
│   │   ├── bswap.h
│   │   ├── buffer.h
│   │   ├── camellia.h
│   │   ├── cast5.h
│   │   ├── channel_layout.h
│   │   ├── common.h
│   │   ├── cpu.h
│   │   ├── crc.h
│   │   ├── csp.h
│   │   ├── des.h
│   │   ├── detection_bbox.h
│   │   ├── dict.h
│   │   ├── display.h
│   │   ├── dovi_meta.h
│   │   ├── downmix_info.h
│   │   ├── encryption_info.h
│   │   ├── error.h
│   │   ├── eval.h
│   │   ├── executor.h
│   │   ├── ffversion.h
│   │   ├── fifo.h
│   │   ├── file.h
│   │   ├── film_grain_params.h
│   │   ├── frame.h
│   │   ├── hash.h
│   │   ├── hdr_dynamic_metadata.h
│   │   ├── hdr_dynamic_vivid_metadata.h
│   │   ├── hmac.h
│   │   ├── hwcontext_cuda.h
│   │   ├── hwcontext_d3d11va.h
│   │   ├── hwcontext_drm.h
│   │   ├── hwcontext_dxva2.h
│   │   ├── hwcontext.h
│   │   ├── hwcontext_mediacodec.h
│   │   ├── hwcontext_opencl.h
│   │   ├── hwcontext_qsv.h
│   │   ├── hwcontext_vaapi.h
│   │   ├── hwcontext_vdpau.h
│   │   ├── hwcontext_videotoolbox.h
│   │   ├── hwcontext_vulkan.h
│   │   ├── imgutils.h
│   │   ├── intfloat.h
│   │   ├── intreadwrite.h
│   │   ├── lfg.h
│   │   ├── log.h
│   │   ├── lzo.h
│   │   ├── macros.h
│   │   ├── mastering_display_metadata.h
│   │   ├── mathematics.h
│   │   ├── md5.h
│   │   ├── mem.h
│   │   ├── motion_vector.h
│   │   ├── murmur3.h
│   │   ├── opt.h
│   │   ├── parseutils.h
│   │   ├── pixdesc.h
│   │   ├── pixelutils.h
│   │   ├── pixfmt.h
│   │   ├── random_seed.h
│   │   ├── rational.h
│   │   ├── rc4.h
│   │   ├── replaygain.h
│   │   ├── ripemd.h
│   │   ├── samplefmt.h
│   │   ├── sha512.h
│   │   ├── sha.h
│   │   ├── spherical.h
│   │   ├── stereo3d.h
│   │   ├── tea.h
│   │   ├── threadmessage.h
│   │   ├── timecode.h
│   │   ├── time.h
│   │   ├── timestamp.h
│   │   ├── tree.h
│   │   ├── twofish.h
│   │   ├── tx.h
│   │   ├── uuid.h
│   │   ├── version.h
│   │   ├── video_enc_params.h
│   │   ├── video_hint.h
│   │   └── xtea.h
│   ├── libswresample
│   │   ├── swresample.h
│   │   ├── version.h
│   │   └── version_major.h
│   └── libswscale
│       ├── swscale.h
│       ├── version.h
│       └── version_major.h
├── lib
│   ├── libavcodec.so -> libavcodec.so.60.31.102
│   ├── libavcodec.so.60 -> libavcodec.so.60.31.102
│   ├── libavcodec.so.60.31.102
│   ├── libavdevice.so -> libavdevice.so.60.3.100
│   ├── libavdevice.so.60 -> libavdevice.so.60.3.100
│   ├── libavdevice.so.60.3.100
│   ├── libavfilter.so -> libavfilter.so.9.12.100
│   ├── libavfilter.so.9 -> libavfilter.so.9.12.100
│   ├── libavfilter.so.9.12.100
│   ├── libavformat.so -> libavformat.so.60.16.100
│   ├── libavformat.so.60 -> libavformat.so.60.16.100
│   ├── libavformat.so.60.16.100
│   ├── libavutil.so -> libavutil.so.58.29.100
│   ├── libavutil.so.58 -> libavutil.so.58.29.100
│   ├── libavutil.so.58.29.100
│   ├── libswresample.so -> libswresample.so.4.12.100
│   ├── libswresample.so.4 -> libswresample.so.4.12.100
│   ├── libswresample.so.4.12.100
│   ├── libswscale.so -> libswscale.so.7.5.100
│   ├── libswscale.so.7 -> libswscale.so.7.5.100
│   ├── libswscale.so.7.5.100
│   └── pkgconfig
│       ├── libavcodec.pc
│       ├── libavdevice.pc
│       ├── libavfilter.pc
│       ├── libavformat.pc
│       ├── libavutil.pc
│       ├── libswresample.pc
│       └── libswscale.pc
└── share
    └── ffmpeg
        └── examples
            ├── avio_http_serve_files.c
            ├── avio_list_dir.c
            ├── avio_read_callback.c
            ├── decode_audio.c
            ├── decode_filter_audio.c
            ├── decode_filter_video.c
            ├── decode_video.c
            ├── demux_decode.c
            ├── encode_audio.c
            ├── encode_video.c
            ├── extract_mvs.c
            ├── filter_audio.c
            ├── hw_decode.c
            ├── Makefile
            ├── mux.c
            ├── qsv_decode.c
            ├── qsv_transcode.c
            ├── README
            ├── remux.c
            ├── resample_audio.c
            ├── scale_video.c
            ├── show_metadata.c
            ├── transcode_aac.c
            ├── transcode.c
            ├── vaapi_encode.c
            └── vaapi_transcode.c

13 directories, 191 files

RTSP拉流demo 发送给海思的Vdec模块进行解码

#include <libavformat/avformat.h>

 HI_VOID *SAMPLE_COMM_VDEC_SendStreamFFmpeg(HI_VOID *pArgs)
    {
        VDEC_THREAD_PARAM_S *pstVdecThreadParam = (VDEC_THREAD_PARAM_S *)pArgs;
        VDEC_STREAM_S stStream;
        HI_U64 u64PTS = 0;
        HI_S32 s32Ret;

        // FFmpeg 打开文件
        AVFormatContext *fmt_ctx = NULL;
        int video_stream_index = -1;
        AVDictionary *avdic=NULL;

        AVPacket *packet = av_packet_alloc();
        if (!packet)
        {
            fprintf(stderr, "Could not allocate packet\n");
            log_e("Could not allocate packet");
            goto end;
        }

        av_dict_set(&avdic, "rtsp_transport", "tcp", 0);
        av_dict_set(&avdic, "max_delay", "500000", 0);
        av_dict_set(&avdic, "stimeout", "1000000", 0);
        av_dict_set(&avdic, "buffer_size", "10240000", 0);

        // Open input file
        s32Ret = avformat_open_input(&fmt_ctx, pstVdecThreadParam->cUrl, NULL, &avdic);
        if (s32Ret < 0)
        {
            fprintf(stderr, "Cannot open input file: %s\n", av_err2str(s32Ret));
            log_e("Cannot open input file: %s", av_err2str(s32Ret));
            goto end;
        }

        // Retrieve stream information
        s32Ret = avformat_find_stream_info(fmt_ctx, NULL);
        if (s32Ret < 0)
        {
            fprintf(stderr, "Cannot find stream information: %s\n", av_err2str(s32Ret));
            log_e("Cannot find stream information: %s", av_err2str(s32Ret));
            goto end;
        }

        // Find the video stream
        s32Ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
        if (s32Ret < 0)
        {
            fprintf(stderr, "Cannot find a video stream in the input file: %s\n", av_err2str(s32Ret));
            log_e("Cannot find a video stream in the input file: %s", av_err2str(s32Ret));
            goto end;
        }
        video_stream_index = s32Ret;

        prctl(PR_SET_NAME, "VideoSendStreamFFmpeg", 0, 0, 0);

        u64PTS = pstVdecThreadParam->u64PtsInit;
        while (1)
        {
            if (pstVdecThreadParam->eThreadCtrl == THREAD_CTRL_STOP)
            {
                break;
            }
            else if (pstVdecThreadParam->eThreadCtrl == THREAD_CTRL_PAUSE)
            {
                sleep(1);
                continue;
            }
            s32Ret = av_read_frame(fmt_ctx, packet);
            if (s32Ret < 0)
                break;

            if (packet->stream_index == video_stream_index)
            {
                // log_d("pts:%ld size:%d\n", packet->pts, packet->size);
                stStream.u64PTS = u64PTS;
                stStream.pu8Addr = packet->data;
                stStream.u32Len = packet->size;
                stStream.bEndOfStream = HI_FALSE;
                stStream.bEndOfFrame = HI_TRUE;
                stStream.bDisplay = 1;

            SendAgain:
                s32Ret = HI_MPI_VDEC_SendStream(pstVdecThreadParam->s32ChnId, &stStream, pstVdecThreadParam->s32MilliSec);
                if ((HI_SUCCESS != s32Ret) && (THREAD_CTRL_START == pstVdecThreadParam->eThreadCtrl))
                {
                    usleep(pstVdecThreadParam->s32IntervalTime);
                    goto SendAgain;
                }

                u64PTS += pstVdecThreadParam->u64PtsIncrease;
                av_packet_unref(packet);
                usleep(pstVdecThreadParam->s32IntervalTime);
            }
        }

    end:
        if (fmt_ctx)
            avformat_close_input(&fmt_ctx);
        av_packet_free(&packet);

        printf("\033[0;35m chn %d send steam thread return ...  \033[0;39m\n", pstVdecThreadParam->s32ChnId);
        fflush(stdout);
        return (HI_VOID *)HI_SUCCESS;
    }

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容