Ubuntu24.04 交叉编译 aarch64 ffmpeg

ffmpeg

安装依赖

bash 复制代码
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

bash 复制代码
./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

然后编译

bash 复制代码
make -j4

安装

bash 复制代码
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

bash 复制代码
$ 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

bash 复制代码
$ objdump -f bin/ffmpeg 

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

readelf

bash 复制代码
$ 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
相关推荐
别动哪条鱼7 小时前
MP4转AAC转换器C++
c++·ffmpeg·音视频·aac
别动哪条鱼8 小时前
FFmpeg 核心数据结构关系图
数据结构·ffmpeg
aqi0013 小时前
FFmpeg开发笔记(九十一)基于Kotlin的Android直播开源框架RootEncoder
android·ffmpeg·kotlin·音视频·直播·流媒体
寻找华年的锦瑟1 天前
Qt-FFmpeg案例(0基础,包含环境配置)
开发语言·qt·ffmpeg
大新新大浩浩1 天前
amazoncorretto:17镜像中安装ffmpeg
ffmpeg
Industio_触觉智能2 天前
瑞芯微RK3562平台FFmpeg硬件编解码移植及性能测试实战攻略
ffmpeg·视频编解码·瑞芯微·rk3562·触觉智能
八月的雨季 最後的冰吻2 天前
FFmepg--25-h265解码yuv格式
ffmpeg
weixin_462446232 天前
Python 使用 FFmpeg 给视频添加内嵌字幕(SRT)完整教程(含代码示例)
python·ffmpeg·音视频
百***35512 天前
从MySQL5.7平滑升级到MySQL8.0的最佳实践分享
ffmpeg
android_cai_niao2 天前
编译最新版本FFmpeg为so
ffmpeg·freetype·harfbuzz·drawtext·文字水印