Last active
June 14, 2022 07:03
-
-
Save dturner/11fe5c8e420c2a73e15537274aafbd3a to your computer and use it in GitHub Desktop.
FFmpeg configure options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$ANDROID_NDK" ]; then | |
echo "Please set ANDROID_NDK to the Android NDK folder" | |
exit 1 | |
fi | |
#Change to your local machine's architecture | |
HOST_OS_ARCH=darwin-x86_64 | |
function configure_ffmpeg { | |
ABI=$1 | |
PLATFORM_VERSION=$2 | |
TOOLCHAIN_PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/${HOST_OS_ARCH}/bin | |
local STRIP_COMMAND | |
# Determine the architecture specific options to use | |
case ${ABI} in | |
armeabi-v7a) | |
TOOLCHAIN_PREFIX=armv7a-linux-androideabi | |
STRIP_COMMAND=arm-linux-androideabi-strip | |
ARCH=armv7-a | |
;; | |
arm64-v8a) | |
TOOLCHAIN_PREFIX=aarch64-linux-android | |
ARCH=aarch64 | |
;; | |
x86) | |
TOOLCHAIN_PREFIX=i686-linux-android | |
ARCH=x86 | |
EXTRA_CONFIG="--disable-asm" | |
;; | |
x86_64) | |
TOOLCHAIN_PREFIX=x86_64-linux-android | |
ARCH=x86_64 | |
EXTRA_CONFIG="--disable-asm" | |
;; | |
esac | |
if [ -z ${STRIP_COMMAND} ]; then | |
STRIP_COMMAND=${TOOLCHAIN_PREFIX}-strip | |
fi | |
echo "Configuring FFmpeg build for ${ABI}" | |
echo "Toolchain path ${TOOLCHAIN_PATH}" | |
echo "Command prefix ${TOOLCHAIN_PREFIX}" | |
echo "Strip command ${STRIP_COMMAND}" | |
./configure \ | |
--prefix=build/${ABI} \ # The path where the resulting libraries and headers will be installed after `make install` is run. The resulting directory structure is "build/{armeabi-v7a,arm64-v8a,x86,x86_64}/{include, lib}". | |
--target-os=android \ # Target operating system name. | |
--arch=${ARCH} \ # Target CPU architecture e.g. armv7-a. | |
--enable-cross-compile \ # We are compiling for a different target architecture than the host. | |
--cc=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}${PLATFORM_VERSION}-clang \ # Path to the C compiler. In our case we're using clang. | |
--strip=${TOOLCHAIN_PATH}/${STRIP_COMMAND} \ # Path to the strip binary for our target architecture. | |
--enable-small \ # Optimize for size instead of speed. | |
--disable-programs \ # Do not build command line programs. We don't need them as our app will be interacting with the FFmpeg API. | |
--disable-doc \ # Do not build documentation. | |
--enable-shared \ # Build shared libraries. We'll keep the FFmpeg .so files separate from our main shared library. | |
--disable-static \ # Do not build static libraries. | |
${EXTRA_CONFIG} \ | |
--disable-everything \ # Disable all modules. To keep the library size to a minimum we will explicitly specify the modules to be built below. | |
--enable-decoder=mp3 \ # Enable the MP3 decoder. For a list of supported decoders type ./configure --help. | |
--enable-demuxer=mp3 # Enable the MP3 demuxer. For a list of supported demuxers type ./configure --help. | |
return $? | |
} | |
function build_ffmpeg { | |
configure_ffmpeg $1 $2 | |
if [ $? -eq 0 ] | |
then | |
make clean | |
make -j12 | |
make install | |
else | |
echo "FFmpeg configuration failed, please check the error log." | |
fi | |
} | |
build_ffmpeg armeabi-v7a 16 | |
build_ffmpeg arm64-v8a 21 | |
build_ffmpeg x86 16 | |
build_ffmpeg x86_64 21 |
Hi Don, I'm getting the following error while executing bash.
./ffmpeg-build.sh: line 59: unexpected EOF while looking for matching `''
./ffmpeg-build.sh: line 87: syntax error: unexpected end of file
I had the same problem. Solution: delete all comments from lines 50 - 64
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dturner thanks. I did not see that