如何使用 Freetype2 為 Android 建立 FFmpeg

如何使用 Freetype2 為 Android 建立 FFmpeg

在 OSX Yosemite 上,我嘗試建立包含 freetype 庫的 FFmpeg(我需要它用於繪圖文字過濾器)。不幸的是,我無法正確配置 ffmpeg,每次嘗試都會以「freetype not found」錯誤結束。

  1. 在沒有 freetype 的情況下建立普通 FFmpeg-2.5.3 效果非常好(如下教程)
  2. 建構 Freetype-2.5.3 也可以正常運作(如下教程)
  3. 包括額外的庫位置,即建構的 freetype 所在的位置,

像這樣:

--extra-ldflags="-L$PREFIX/lib" 
--extra-cflags="-I$PREFIX/include -I$PREFIX/include/freetype2"
  1. ./build_android.sh最終以ERROR: freetype2 not found

build_android.sh:

#!/bin/bash
NDK=$HOME/Desktop/adt/android-ndk-r10d
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64
function build_one
{
./configure \
 --prefix=$PREFIX \
 --enable-shared \
 --disable-static \
 --enable-libfreetype \
 --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
 --target-os=linux \
 --arch=arm \
 --enable-cross-compile \
 --sysroot=$SYSROOT \
 --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
 --extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}

CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm -I$PREFIX/include"
ADDI_LDFLAGS="-L$PREFIX/lib"
build_one

config.log 的最後 3 行:

require_libfreetype
false --exists --print-errors freetype2
ERROR: freetype2 not found

預先感謝(並為我糟糕的英語感到抱歉)

PS:我檢查了guardian-project中的補丁來源,發現了這個:

# this is a fake pkg-config since ffmpeg requires pkg-config if you want to
# include external libraries like libfreetype or libass.  The Android NDK does
# not provide any kind of pkg-config.

這是否意味著我必須遷移到 Linux? OSX 上沒有安裝 pkg-config 嗎?

algakzru$ pkg-config --version
0.28

答案1

我讓它與 ffmpeg 建置的監護人專案版本一起使用(用於命令列輸出)。在這裡查看我的叉子:

https://github.com/touchlab/android-ffmpeg

本質上,您需要將 ffmpeg 配置為使用 fake-pkg-config,並修改它以查看參數 3 而不是參數 2(位於我的 fork 中)。分叉版本的頂部有一些說明。我剛剛運行了一個測試版本,據此,您可以忽略有關修復 ffmpeg/libavutil/arm/intmath.h 中的註釋的部分。只需更改 ffmpeg/configure 即可。

最初,ffmpeg/configure 的更改是透過 config_ffmpeg.sh 中的補丁完成的,但我完全刪除了補丁,並且沒有製作新的補丁。更新子模組版本後,補丁不再有效。

另外,作為參考,我使用的是 ndk r10c 版本。

從今天(2/8/2015)開始,ffmpeg、freetype2 和 x264 都應該成為 master。我最終可能會將它們固定到一個版本,但它在我的優先列表中並不是很高,所以...

相關內容