Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ag2s20150909 committed Jan 17, 2024
1 parent bc88e9e commit 16e5249
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 39 deletions.
61 changes: 43 additions & 18 deletions .github/scripts/build-ffmpeg.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#!/bin/bash
set -eux

echo "Build FFmpeg"
echo $ANDROID_NDK_HOME
echo $NDK_PATH
set -eu

FFMPEG_MODULE_PATH="${MEDIA3_PATH}/libraries/decoder_ffmpeg/src/main"
GD_PATH="${MEDIA3_PATH}/libraries/decoder_ffmpeg/build.gradle"

cat "${GD_PATH}"

echo "
android {
namespace 'androidx.media3.decoder.ffmpeg'
Expand All @@ -27,21 +21,36 @@ ext {
apply from: '../../publish.gradle'
">>"${GD_PATH}"

cat "${GD_PATH}"


#cat "${GD_PATH}"

echo "Build FFmpeg"
echo $ANDROID_NDK_HOME
echo $NDK_PATH
ANDROID_ABI=16
HOST_PLATFORM="linux-x86_64"
ENABLED_DECODERS=(vorbis opus flac alac pcm_mulaw pcm_alaw mp3 aac ac3 eac3 dca mlp truehd)


echo "NDK path is ${NDK_PATH}"
echo "FFMPEG_MODULE_PATH is ${FFMPEG_MODULE_PATH}"
echo "Host platform is ${HOST_PLATFORM}"
echo "ANDROID_ABI is ${ANDROID_ABI}"
echo "Enabled decoders are ${ENABLED_DECODERS[@]}"


cd "${FFMPEG_MODULE_PATH}/jni"

git clone --depth=1 -b release/4.2 git://source.ffmpeg.org/ffmpeg
rm -rf ffmpeg

git clone --depth=1 -b release/6.0 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
FFMPEG_PATH="$(pwd)"
pwd

JOBS=$(nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 4)
echo "Using $JOBS jobs for make"


COMMON_OPTIONS="
--target-os=android
--enable-static
Expand All @@ -55,21 +64,37 @@ COMMON_OPTIONS="
--disable-postproc
--disable-avfilter
--disable-symver
--disable-avresample
--enable-swresample
--extra-ldexeflags=-pie
--disable-v4l2-m2m
--disable-vulkan
"
TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
for decoder in "${ENABLED_DECODERS[@]}"
do
COMMON_OPTIONS="${COMMON_OPTIONS} --enable-decoder=${decoder}"
done
cd "${FFMPEG_PATH}"

ARMV7_CLANG="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi${ANDROID_ABI}-clang"
if [[ -e "${TOOLCHAIN_PREFIX}" && ! -e "$ARMV7_CLANG" ]]
then
echo "AVMv7 Clang compiler with path $ARMV7_CLANG does not exist"
echo "It's likely your NDK version doesn't support ANDROID_ABI $ANDROID_ABI"
echo "Either use older version of NDK or raise ANDROID_ABI (be aware that ANDROID_ABI must not be greater than your application's minSdk)"
exit 1
fi
ANDROID_ABI_64BIT="$ANDROID_ABI"
if [[ "$ANDROID_ABI_64BIT" -lt 21 ]]
then
echo "Using ANDROID_ABI 21 for 64-bit architectures"
ANDROID_ABI_64BIT=21
fi

./configure \
--libdir=android-libs/armeabi-v7a \
--arch=arm \
--cpu=armv7-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-" \
--cross-prefix="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi${ANDROID_ABI}-" \
--nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
--ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
--ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
Expand All @@ -84,7 +109,7 @@ make clean
--libdir=android-libs/arm64-v8a \
--arch=aarch64 \
--cpu=armv8-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-" \
--cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android${ANDROID_ABI_64BIT}-" \
--nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
--ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
--ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
Expand All @@ -97,7 +122,7 @@ make clean
--libdir=android-libs/x86 \
--arch=x86 \
--cpu=i686 \
--cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android16-" \
--cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android${ANDROID_ABI}-" \
--nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
--ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
--ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
Expand All @@ -110,8 +135,8 @@ make clean
./configure \
--libdir=android-libs/x86_64 \
--arch=x86_64 \
--cpu=x86_64 \
--cross-prefix="${TOOLCHAIN_PREFIX}/x86_64-linux-android21-" \
--cpu=x86-64 \
--cross-prefix="${TOOLCHAIN_PREFIX}/x86_64-linux-android${ANDROID_ABI_64BIT}-" \
--nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
--ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
--ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export MEDIA3_PATH="$(pwd)"
${ROOT_DIR}/.github/scripts/build-ffmpeg.sh
${ROOT_DIR}/.github/scripts/build-av1.sh
cd ${MEDIA3_PATH}
./gradlew publishToMavenLocal
./gradlew publishToMavenLocal --scan


cd ${ROOT_DIR}
Expand Down
37 changes: 17 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,27 @@ jobs:
distribution: temurin
java-version: 17

- name: Set up Gradle
uses: gradle/gradle-build-action@v2
# - name: Set up Gradle
# uses: gradle/gradle-build-action@v2


# Set up NDK
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21e
ndk-version: r23c
local-cache: true
add-to-path: true
# Build FFmpeg
- name: Build FFmpeg
# Build
- name: Build
continue-on-error: true
env:
ANDROID_NDK_HOME: ${{steps.setup-ndk.outputs.ndk-path }}
NDK_PATH: ${{ steps.setup-ndk.outputs.ndk-path }}
ROOT_DIR: ${{ github.workspace }}
run: |
echo "build ffmpeg"
source ${{ github.workspace }}/.github/scripts/build.sh
cd ${{ github.workspace }}/media
./gradlew publishToMavenLocal
echo "Build Success"
Expand All @@ -61,30 +60,28 @@ jobs:
# Runs a set of commands using the runners shell
- name: Upload FFmpeg Static Libs
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: "ffmpeg"
path: ${{ github.workspace }}/media/libraries/decoder_ffmpeg/src/main/jni/ffmpeg/android-libs

- name: Upload library
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: aar-library
path: ~/.m2
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
continue-on-error: true


- name: Push
uses: ad-m/github-push-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: repo
commit-message: build aar
title: Automated Build
body: This is an auto-generated PR .
delete-branch: true
add-paths: |
**.aar
**.jar
repo/**
force: true
tags: true
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: 'repo'




4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.iml
.gradle
/.idea
/.vscode

0 comments on commit 16e5249

Please sign in to comment.