Merge pull request #6 from Javernaut/variable_ffmpeg_version

Variable ffmpeg version
ffmpeg_4.4.2
Alexander Kobozev 5 years ago committed by GitHub
commit a6b0488d75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      README.md
  2. 63
      ffmpeg-android-maker.sh

@ -3,7 +3,7 @@
Here is a script that downloads the source code of [FFmpeg](https://www.ffmpeg.org) library and assembles it for Android. The script produces shared libraries as well as header files. The output structure looks like this: Here is a script that downloads the source code of [FFmpeg](https://www.ffmpeg.org) library and assembles it for Android. The script produces shared libraries as well as header files. The output structure looks like this:
<img src="https://github.com/Javernaut/ffmpeg-android-maker/blob/master/images/output_structure.png" width="200"> <img src="https://github.com/Javernaut/ffmpeg-android-maker/blob/master/images/output_structure.png" width="200">
The actual content of all this directories depends on how the FFmpeg was configured before assembling. For my purpose I enabled only *libavcodec*, *libavformat*, *libavutil* and *libswscale*, but you can set your own configuration to make the FFmpeg you need. The actual content of all this directories depends on how the FFmpeg was configured before assembling. For my purpose I enabled only *libavcodec*, *libavformat*, *libavutil* and *libswscale*, but you can set your own configuration to make the FFmpeg you need.
The version of FFmpeg here is **4.1.4**. And the script expects to use **at least** Android NDK **r19** (*r20* also works ok). Starting with FFmpeg 4.1 and NDK r19 the whole process became much simpler. The version of FFmpeg here by default is **4.1.4** (but can be overridden). And the script expects to use **at least** Android NDK **r19** (*r20* also works ok). Starting with FFmpeg 4.1 and NDK r19 the whole process became much simpler.
## Supported architectures ## Supported architectures
@ -24,4 +24,6 @@ And the actual Android app can be found [here](https://github.com/Javernaut/What
## Features ## Features
**Setting your own FFmpeg version**. You can actually override the version of FFmpeg used by the script. See details [here](https://github.com/Javernaut/ffmpeg-android-maker/wiki/Invocation-parameters).
**Text relocations monitoring**. After a build you can look into stats/text-relocations.txt file. That file lists all *.so files that were built and reports if they have text relocations. If you don't see any mentioning of 'TEXTREL' in the file, you are good. Otherwise, you will see exact binaries that have this problem. **Text relocations monitoring**. After a build you can look into stats/text-relocations.txt file. That file lists all *.so files that were built and reports if they have text relocations. If you don't see any mentioning of 'TEXTREL' in the file, you are good. Otherwise, you will see exact binaries that have this problem.

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
FFMPEG_VERSION=4.1.4 FFMPEG_FALLBACK_VERSION=4.1.4
# Assuming the script is used on macOS or Linux machine # Assuming the script is used on macOS or Linux machine
case "$OSTYPE" in case "$OSTYPE" in
@ -11,7 +11,6 @@ esac
# Directories used by the script # Directories used by the script
BASE_DIR="$( cd "$( dirname "$0" )" && pwd )" BASE_DIR="$( cd "$( dirname "$0" )" && pwd )"
SOURCES_DIR=${BASE_DIR}/sources SOURCES_DIR=${BASE_DIR}/sources
FFMPEG_SOURCES=${SOURCES_DIR}/ffmpeg-${FFMPEG_VERSION}
OUTPUT_DIR=${BASE_DIR}/output OUTPUT_DIR=${BASE_DIR}/output
BUILD_DIR=${BASE_DIR}/build BUILD_DIR=${BASE_DIR}/build
STATS_DIR=${BASE_DIR}/stats STATS_DIR=${BASE_DIR}/stats
@ -23,8 +22,13 @@ rm -rf ${OUTPUT_DIR}
mkdir -p ${STATS_DIR} mkdir -p ${STATS_DIR}
mkdir -p ${OUTPUT_DIR} mkdir -p ${OUTPUT_DIR}
# Test if sources of the FFmpeg exist. If not - download them # Getting sources of a particular ffmpeg release.
function ensureSources() { # Same argument (ffmpeg version) produces the same source set.
function ensureSourcesTag() {
FFMPEG_VERSION=$1
FFMPEG_SOURCES=${SOURCES_DIR}/ffmpeg-${FFMPEG_VERSION}
if [[ ! -d "$FFMPEG_SOURCES" ]]; then if [[ ! -d "$FFMPEG_SOURCES" ]]; then
TARGET_FILE_NAME=ffmpeg-${FFMPEG_VERSION}.tar.bz2 TARGET_FILE_NAME=ffmpeg-${FFMPEG_VERSION}.tar.bz2
TARGET_FILE_PATH=${SOURCES_DIR}/${TARGET_FILE_NAME} TARGET_FILE_PATH=${SOURCES_DIR}/${TARGET_FILE_NAME}
@ -36,6 +40,55 @@ function ensureSources() {
fi fi
} }
# Getting sources of a particular branch of ffmpeg's git repository.
# Same argument (branch name) may produce different source set,
# as the branch in origin repository may be updated in future.
function ensureSourcesBranch() {
BRANCH=$1
GIT_DIRECTORY=ffmpeg-git
FFMPEG_SOURCES=${SOURCES_DIR}/${GIT_DIRECTORY}
cd ${SOURCES_DIR}
if [[ ! -d "$FFMPEG_SOURCES" ]]; then
git clone https://git.ffmpeg.org/ffmpeg.git ${GIT_DIRECTORY}
fi
cd ${GIT_DIRECTORY}
git checkout $BRANCH
# Forcing the update of a branch
git pull origin $BRANCH
# Additional logging to keep track of an exact commit to build
echo "Commit to build:"
git rev-parse HEAD
cd ${BASE_DIR}
}
# Test if sources of the FFmpeg exist. If not - download them
function ensureSources() {
TYPE=$1
SECOND_ARGUMENT=$2
case $TYPE in
tag)
echo "Using FFmpeg ${SECOND_ARGUMENT}"
ensureSourcesTag ${SECOND_ARGUMENT}
;;
branch)
echo "Using FFmpeg git repository and its branch ${SECOND_ARGUMENT}"
ensureSourcesBranch ${SECOND_ARGUMENT}
;;
*)
echo "Using FFmpeg 4.1.4"
ensureSourcesTag ${FFMPEG_FALLBACK_VERSION}
;;
esac
}
# Actual magic of configuring and compiling of FFmpeg for a certain architecture. # Actual magic of configuring and compiling of FFmpeg for a certain architecture.
# Supported architectures are: armeabi-v7a, arm64-v8a, x86 and x86_64 # Supported architectures are: armeabi-v7a, arm64-v8a, x86 and x86_64
function assemble() { function assemble() {
@ -153,7 +206,7 @@ function installHeaders() {
# Actual work # Actual work
ensureSources ensureSources $1 $2
build armeabi-v7a 16 build armeabi-v7a 16
build arm64-v8a 21 build arm64-v8a 21

Loading…
Cancel
Save