반응형
우분투에서 abi별로 FFMPEG 컴파일 하는 방법
FFMPEG은 4.0 버전
NDK 15버전
apt install make
apt install vim
apt install unzip
apt-get install yasm
mkdir /var/android/abi
mkdir /var/android/abi/ndk
wget http://ffmpeg.org/releases/ffmpeg-4.0.tar.xz
tar -xvf ffmpeg-4.0.tar.xz
wget https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip
unzip android-ndk-r15c-linux-x86_64.zip
vim /var/android/abi/ffmpeg-4.0/configure
# SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
# LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
# SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
# SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'
vim /var/android/abi/ffmpeg-4.0/libavcodec/hevc_mvs.c
:%s/B0/bb/gc
vim /var/android/ndk/android-ndk-r15c/platforms/android-24/arch-arm/usr/include/asm/termbits.h
:%s/B0/bb/gc
/var/android/abi# vim /var/android/abi/ffmpeg-4.0/libavcodec/aaccoder.c
:%s/B0/bb/gc
vim /var/android/abi/build.sh
#!/bin/sh
MY_LIBS_NAME=ffmpeg-4.0
MY_DIR=ffmpeg-4.0
# cd ./${MY_DIR}
#The storage directory of the middleware generated during the compilation process, in order to distinguish the compilation directory, source code directory, install directory
MY_BUILD_DIR=/var/android/abi/binary
NDK_PATH=/var/android/ndk/android-ndk-r15c
BUILD_PLATFORM=linux-x86_64
TOOLCHAIN_VERSION=4.9
ANDROID_VERSION=24
ANDROID_ARMV5_CFLAGS="-march=armv5te"
ANDROID_ARMV7_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon" #-mfloat-abi=hard -mfpu=vfpv3-d16 #-mfloat-abi=hard -mfpu=vfp
ANDROID_ARMV8_CFLAGS="-march=armv8-a"
ANDROID_X86_CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32"
ANDROID_X86_64_CFLAGS="-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel"
# params($1:arch,$2:arch_abi,$3:host,$4:cross_prefix,$5:cflags)
build_bin() {
echo "-------------------star build $2-------------------------"
ARCH=$1 # arm arm64 x86 x86_64
ANDROID_ARCH_ABI=$2 # armeabi armeabi-v7a x86 mips
PREFIX=$(pwd)/dist/${MY_LIBS_NAME}/${ANDROID_ARCH_ABI}/
HOST=$3
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-${ARCH}
CFALGS=$5
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
CROSS_PREFIX=${TOOLCHAIN}/bin/$4-
# build middleware
BUILD_DIR=${MY_BUILD_DIR}/${ANDROID_ARCH_ABI}
#/var/android/abi/binary/armeabi
echo "pwd==$(pwd)"
echo "ARCH==${ARCH}"
echo "PREFIX==${PREFIX}"
echo "HOST==${HOST}"
echo "SYSROOT=${SYSROOT}"
echo "CFALGS=$5"
echo "CFALGS=${CFALGS}"
echo "TOOLCHAIN==${TOOLCHAIN}"
echo "CROSS_PREFIX=${CROSS_PREFIX}"
echo "BUILD_DIR=${BUILD_DIR}"
cd
mkdir -p ${BUILD_DIR} #Create the current arch_abi compilation directory, for example: binary/armeabi-v7a
cd ${BUILD_DIR} #Here into the current arch_abi level 2 compilation directory
sh ../../${MY_DIR}/configure \
--prefix=${PREFIX} \
--target-os=linux \
--arch=${ARCH} \
--sysroot=$SYSROOT \
--enable-cross-compile \
--cross-prefix=${CROSS_PREFIX} \
--extra-cflags="$CFALGS -Os -fPIC -DANDROID -Wfatal-errors -Wno-deprecated" \
--extra-cxxflags="$CFALGS -Os -fPIC -DANDROID -D__thumb__ -Wfatal-errors -Wno-deprecated -fexceptions -frtti" \
--extra-ldflags="-L${SYSROOT}/usr/lib" \
--enable-shared \
--disable-encoders \
--disable-encoders \
--enable-encoder=aac \
--enable-decoder=aac_latm \
--enable-decoder=h264 \
--enable-decoder=mpeg4 \
--enable-decoder=mjpeg \
--enable-decoder=png \
--disable-demuxers \
--enable-demuxer=image2 \
--enable-demuxer=h264 \
--enable-demuxer=aac \
--disable-parsers \
--enable-parser=aac \
--enable-parser=ac3 \
--enable-parser=h264 \
--enable-gpl \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-symver \
--disable-debug \
--enable-small
make clean
make
make install
cd ../../
echo "-------------------$2 build end-------------------------"
}
# build armeabi
build_bin arm armeabi arm-linux-androideabi arm-linux-androideabi "$ANDROID_ARMV5_CFLAGS"
#build armeabi-v7a
build_bin arm armeabi-v7a arm-linux-androideabi arm-linux-androideabi "$ANDROID_ARMV7_CFLAGS"
#build arm64-v8a
build_bin arm64 arm64-v8a aarch64-linux-android aarch64-linux-android "$ANDROID_ARMV8_CFLAGS"
#build x86
build_bin x86 x86 x86 i686-linux-android "$ANDROID_X86_CFLAGS"
#build x86_64
build_bin x86_64 x86_64 x86_64 x86_64-linux-android "$ANDROID_X86_64_CFLAGS"
chmod 755 build.sh
./build.sh
반응형
'OS > Linux' 카테고리의 다른 글
nslookup url로 ip 정보 확인 (0) | 2021.09.20 |
---|---|
ubuntu 모스키토 설치 (0) | 2021.07.14 |
FFMPEG Android Build (0) | 2021.03.05 |
centos7 Gradle Install (0) | 2020.12.24 |
Centos7 Crontab php 실행안됨 (0) | 2020.12.17 |