diff --git a/.github/workflows/compilability_check.yml b/.github/workflows/compilability_check.yml deleted file mode 100644 index be57a90..0000000 --- a/.github/workflows/compilability_check.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Compilability check -on: [push, pull_request] -jobs: - build: - runs-on: ubuntu-22.04 - strategy: - matrix: - abi: [ "armeabi-v7a", "arm64-v8a", "x86", "x86_64" ] - fail-fast: false - steps: - - uses: actions/checkout@v3 - - - name: Setup the environment - run: | - sudo pip3 install meson==1.0.1 - sudo apt-get install nasm ninja-build - - - name: Executing the script - run: | - export ANDROID_SDK_HOME=$ANDROID_HOME - export ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME - ./ffmpeg-android-maker.sh -all-free -all-gpl -android=21 -abis=${{ matrix.abi }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9036777..ca731fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ build -output sources stats .DS_Store diff --git a/README.md b/README.md index bb91d0a..29de31f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,14 @@ [![Android Weekly #378](https://androidweekly.net/issues/issue-378/badge)](https://androidweekly.net/issues/issue-378) [![Android Weekly #396](https://androidweekly.net/issues/issue-396/badge)](https://androidweekly.net/issues/issue-396) - + +这个工程是基于[ffmpeg-android-maker](https://github.com/Javernaut/ffmpeg-android-maker) 修改而来,在此基础上把多个SO合并成了一个SO, 并且裁剪了很多Android日常开发不需要的库,目前SO大小为6M,最低可以裁剪到2M左右,有需要的可以自己裁剪,默认编译了FFmpeg 6.0.0,5.1.1, 4.4.2, 3.4.8,以及集成了libmp3lame,libx264并上传到了github上,大家可以直接使用 + +This project is based on [ffmpeg-android-maker](https://github.com/Javernaut/ffmpeg-android-maker) with modifications. On this basis, multiple dynamic link libraries (SO) are merged into one and many unnecessary libraries for Android daily development are trimmed. The current size of the SO is 6MB, which can be further trimmed to about 2MB according to specific needs. FFmpeg versions including 6.0.0, 5.1.1, 4.4.2, and 3.4.8 are compiled by default, and libmp3lame and libx264 are integrated. This project has been uploaded to Github for direct use. + + + + 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 (\*.so files) as well as header files (\*.h files). The output structure is represented in the image. diff --git a/images/all_branch.png b/images/all_branch.png new file mode 100644 index 0000000..777401a Binary files /dev/null and b/images/all_branch.png differ diff --git a/images/all_lib.png b/images/all_lib.png new file mode 100644 index 0000000..c5fbed9 Binary files /dev/null and b/images/all_lib.png differ diff --git a/images/output_structure.png b/images/output_structure.png deleted file mode 100644 index 479f3c6..0000000 Binary files a/images/output_structure.png and /dev/null differ diff --git a/scripts/ffmpeg/build.sh b/scripts/ffmpeg/build.sh index 9621e75..6801310 100755 --- a/scripts/ffmpeg/build.sh +++ b/scripts/ffmpeg/build.sh @@ -3,10 +3,16 @@ case $ANDROID_ABI in x86) # Disabling assembler optimizations, because they have text relocations - EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --disable-asm" + EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --disable-neon --disable-asm" ;; x86_64) - EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --x86asmexe=${FAM_YASM}" + EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --disable-neon --disable-asm" + ;; + armeabi-v7a) + EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-neon --disable-asm --enable-inline-asm" + ;; + arm64-v8a) + EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-neon --disable-asm --enable-inline-asm" ;; esac @@ -40,7 +46,7 @@ DEP_LD_FLAGS="-L${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/lib $FFMPEG_EXTRA_LD_FLAGS" --nm=${FAM_NM} \ --ranlib=${FAM_RANLIB} \ --strip=${FAM_STRIP} \ - --extra-cflags="-O3 -fPIC $DEP_CFLAGS" \ + --extra-cflags="-O3 -fPIC -lm -lz -landroid $DEP_CFLAGS" \ --extra-ldflags="$DEP_LD_FLAGS" \ --disable-shared \ --enable-static \ @@ -168,7 +174,7 @@ done echo EXTERNAL_STATIC_LIB_PATH=${EXTERNAL_STATIC_LIB_PATH} ${FAM_CC} -shared -o ${STATIC_LIB_DIR}/${OUTPUT_SO_NAME} \ - -Wl,--whole-archive,-Bsymbolic \ + -Wl,--whole-archive \ ${EXTERNAL_STATIC_LIB_PATH}\ ${STATIC_LIB_DIR}/libavutil.a \ ${STATIC_LIB_DIR}/libavcodec.a \ @@ -176,7 +182,11 @@ ${FAM_CC} -shared -o ${STATIC_LIB_DIR}/${OUTPUT_SO_NAME} \ ${STATIC_LIB_DIR}/libswresample.a \ ${STATIC_LIB_DIR}/libavformat.a \ ${STATIC_LIB_DIR}/libswscale.a \ - -Wl,--no-whole-archive + -Wl,--no-whole-archive -lm -lz -landroid + +OUTPUT_CONFIG_HEADERS_DIR=${OUTPUT_DIR}/include/${ANDROID_ABI} +mkdir -p ${OUTPUT_CONFIG_HEADERS_DIR} +cp config.h ${OUTPUT_CONFIG_HEADERS_DIR}/config.h ${FAM_STRIP} --strip-unneeded ${STATIC_LIB_DIR}/${OUTPUT_SO_NAME}