This repository is an example of using FFmpeg to compress video.
Refer this guide in FFmpeg wiki, recommended to use ffmpeg-android-maker, see details below.
-
Install Android Studio. If you do not need it, install command line tools only.
-
Install latest NDK and export environment variables.
sdkmanager "ndk;${ndk_version}" # For command line tools only export ANDROID_SDK_HOME=/path/to/Android_sdk export ANDROID_NDK_HOME=${ANDROID_SDK_HOME}/ndk/${ndk_version}
-
Clone
ffmpeg-android-makerrepository and build.git clone https://github.com/Javernaut/ffmpeg-android-maker cd ffmpeg-android-maker export FFMPEG_ANDROID=`pwd` ./ffmpeg-android-maker.sh
-
The
.sofiles are located in${FFMPEG_ANDROID}/build/ffmpeg/${ANDROID_ABI}/lib, copy them to the project.cd /path/to/NDKFFmpeg mkdir -p app/src/main/jniLibs/${ANDROID_ABI} cp /path/to/*.so app/src/main/jniLibs/${ANDROID_ABI}
-
Locate the source code of FFmpeg.
- If compile this project on the same machine used to compile FFmpeg, the source is located
at
${FFMPEG_ANDROID}/source/ffmpeg/ffmpeg-${ffmpeg_version} - If compile this project on another machine, download source code of FFmpeg.
- If compile this project on the same machine used to compile FFmpeg, the source is located
at
-
Set
FFMPEG_SOURCE_DIRto ensure that CMake can work.export FFMPEG_SOURCE_DIR=/path/to/ffmpeg_source cd ${FFMPEG_SOURCE_DIR} rm VERSION # This file will cause error
Remember to copy the following missing headers if compile this project on another machine.
config.h libavutil/avconfig.h libavutil/ffversion.h -
Open the project with Android Studio, build and run.