编译不依赖动态库的FFMPEG(麒麟国防 V10)

一、为了让ffmpeg 包含 H.264 需要先编译并安装 x264(ARM64 原生)

bash 复制代码
cd /usr/local/src
git clone https://code.videolan.org/videolan/x264.git
cd x264

./configure \
    --enable-static \
    --disable-shared \
    --enable-pic

make -j$(nproc)
make install

二、确认 x264 是否安装成功

bash 复制代码
[root@localhost ~]# ls /usr/local/lib | grep x264
libx264.a

[root@localhost ~]# ls /usr/local/include | grep x264
x264_config.h
x264.h

如果这两个( libx264.a,x264.h )都存在,说明 x264 安装成功。

如果仍然没有 libx264.a 那可能是你的系统把库装到了其他位置,查询一下

bash 复制代码
find / -name "libx264.a" 

三、编译 FFmpeg(静态 + x264)

bash 复制代码
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg


./configure \
    --prefix=/opt/local/ffmpeg \
    --enable-gpl \
    --enable-libx264 \
    --enable-static \
    --disable-shared \
    --disable-debug \
    --disable-doc \
    --pkg-config-flags="--static" \
    --extra-cflags="-I/usr/local/include" \
    --extra-ldflags="-L/usr/local/lib" \
    --extra-ldexeflags="-static"
bash 复制代码
make -j 4
make install

四、最终产物(可离线分发)

bash 复制代码
/opt/local/ffmpeg/bin/ffmpeg
/opt/local/ffmpeg/bin/ffprobe

验证是否包含 H.264

bash 复制代码
[root@localhost bin]# ffmpeg -codecs | grep 264
ffmpeg version 4.2.5 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=aarch64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/kylin/kylin-hardened-cc1 -fasynchronous-unwind-tables -fstack-clash-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/kylin/kylin-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: libx264 libx264rgb h264_v4l2m2m h264_vaapi )
[root@localhost bin]# 

验证是否是静态编译

bash 复制代码
如果是完全静态编译,ldd 会输出:


[root@localhost bin]# ldd ffmpeg
        不是动态可执行文件
[root@localhost bin]# ldd ffprobe 
        不是动态可执行文件


如果不是静态,会看到类似:


linux-vdso.so.1 =>  (0x0000fffff7ffd000)
libpthread.so.0 => /lib64/libpthread.so.0
libm.so.6 => /lib64/libm.so.6
libc.so.6 => /lib64/libc.so.6
相关推荐
2401_854151557 小时前
ARM Cortex-M 体系结构深度解析——寄存器模型、处理器模式、AAPCS 与异常模型
arm开发·stm32·单片机·嵌入式硬件
阿拉斯攀登13 小时前
售货柜实战:IPC 拉流 → 抽帧 → YOLO 识别完整流水线
yolo·ffmpeg·音视频·webrtc·视频编解码
阿拉斯攀登16 小时前
RTSP 拉流与录制:IPC 摄像头本地录像完整方案
ffmpeg·音视频·webrtc·实时音视频·视频编解码
zlinear数据采集卡1 天前
从0到1硬核拆解:工业级数据采集卡的隔离设计与Modbus通信实战
arm开发·单片机·嵌入式硬件·fpga开发·开源
坐望云起1 天前
FFmpeg.wasm 纯浏览器端视频压缩与格式转换实战:零服务器、零上传、100% 隐私
服务器·ffmpeg·wasm
阿拉斯攀登2 天前
FFmpeg 转码详解:封装格式、编码器、码率控制
ffmpeg·音视频·webrtc·实时音视频·视频编解码
阿拉斯攀登2 天前
FFmpeg 入门:命令行的 20 个常用场景
ffmpeg·音视频·webrtc·视频编解码
luoyayun3613 天前
Qt + FFmpeg 音频工具:重采样实现
qt·ffmpeg·重采样
薄荷椰果抹茶4 天前
计算机导论_第6章_笔记
笔记·ffmpeg
zlinear数据采集卡4 天前
从协议解析到波形实时显示:硬核拆解ZLinear采集卡上位机软件的开发架构
arm开发·单片机·嵌入式硬件·fpga开发·架构·开源