Ubuntu24.04 交叉编译 aarch64 ffmpeg

发布于:2025-06-06 ⋅ 阅读:(21) ⋅ 点赞:(0)

ffmpeg

安装依赖

sudo apt install \
  autoconf \
  automake \
  build-essential \
  cmake \
  git-core \
  libass-dev \
  libfreetype6-dev \
  libgnutls28-dev \
  libmp3lame-dev \
  libsdl2-dev \
  libtool \
  libva-dev \
  libvdpau-dev \
  libvorbis-dev \
  libxcb1-dev \
  libxcb-shm0-dev \
  libxcb-xfixes0-dev \
  meson \
  ninja-build \
  pkg-config \
  texinfo \
  wget \
  yasm \
  zlib1g-dev

sudo apt install libunistring-dev libaom-dev libdav1d-dev

下载源代码

下载页拉到下方 Releases 位置, 下载最新的代码包, 当前版本是 FFmpeg 7.1.1 “Péter”

解压到本地, 在与 ffmpeg-7.1.1 同一级目录下再建一个目录用作 install 的目标目录

configure

设置交叉编译的gcc工具链路径, 设置 install 的目标路径

通过./configure --help可以查看所有的选项.

如果只编译指定的解码器, 可以用--disable-decoders --enable-decoder=h264这样的参数组合, 编码器也是同理.

默认编译所有的编解码器, 执行 configure

./configure --enable-cross-compile --target-os=linux --arch=arm64 \
--cross-prefix=/opt/gcc-arm/aarch64-buildroot-linux-gnu-gcc-12.3.0/bin/aarch64-buildroot-linux-gnu- \
--cc=/opt/gcc-arm/aarch64-buildroot-linux-gnu-gcc-12.3.0/bin/aarch64-buildroot-linux-gnu-gcc \
--cxx=/opt/gcc-arm/aarch64-buildroot-linux-gnu-gcc-12.3.0/bin/aarch64-buildroot-linux-gnu-g++ \
--prefix=/home/milton/WorkC/ffmpeg-7.1.1-lib \
--disable-asm  --enable-parsers --disable-debug \
--enable-ffmpeg --enable-shared --disable-static \
--disable-stripping --disable-doc

然后编译

make -j4

安装

make install

会在目录下生成对应的 bin, include 和 lib

├── bin
│   ├── ffmpeg
│   └── ffprobe
├── include
│   ├── libavcodec
│   ├── libavdevice
│   ├── libavfilter
│   ├── libavformat
│   ├── libavutil
│   ├── libswresample
│   └── libswscale
├── lib
│   ├── libavcodec.so -> libavcodec.so.61.19.101
│   ├── libavcodec.so.61 -> libavcodec.so.61.19.101
│   ├── libavcodec.so.61.19.101
|   |   ...
│   ├── libswscale.so.8 -> libswscale.so.8.3.100
│   ├── libswscale.so.8.3.100
│   └── pkgconfig
└── share
    └── ffmpeg

查看二进制文件是X64还是Aarch64

file

$ file bin/ffmpeg
bin/ffmpeg: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, with debug_info, not stripped

objdump

$ objdump -f bin/ffmpeg 

bin/ffmpeg:     file format elf64-little
architecture: UNKNOWN!, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x000000000000edc0

readelf

$ readelf -h bin/ffmpeg
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Position-Independent Executable file)
  Machine:                           AArch64
  Version:                           0x1
  Entry point address:               0xedc0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          382240 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         37
  Section header string table index: 36

网站公告

今日签到

点亮在社区的每一天
去签到