Merge multiple ffmpeg libs to libffmpeg.so

master
徐灿辉 5 years ago
parent 8d8326260d
commit 97c5067331
  1. 1
      app/build.gradle
  2. 103
      build_ffmpeg.sh
  3. 71
      library/CMakeLists.txt
  4. BIN
      library/libs/arm64-v8a/libavcodec.so
  5. BIN
      library/libs/arm64-v8a/libavfilter.so
  6. BIN
      library/libs/arm64-v8a/libavformat.so
  7. BIN
      library/libs/arm64-v8a/libavresample.so
  8. BIN
      library/libs/arm64-v8a/libavutil.so
  9. BIN
      library/libs/arm64-v8a/libffmpeg.so
  10. BIN
      library/libs/arm64-v8a/libswresample.so
  11. BIN
      library/libs/arm64-v8a/libswscale.so
  12. BIN
      library/libs/armeabi-v7a/libavcodec.so
  13. BIN
      library/libs/armeabi-v7a/libavfilter.so
  14. BIN
      library/libs/armeabi-v7a/libavformat.so
  15. BIN
      library/libs/armeabi-v7a/libavresample.so
  16. BIN
      library/libs/armeabi-v7a/libavutil.so
  17. BIN
      library/libs/armeabi-v7a/libffmpeg.so
  18. BIN
      library/libs/armeabi-v7a/libswresample.so
  19. BIN
      library/libs/armeabi-v7a/libswscale.so
  20. BIN
      library/libs/x86/libavcodec.so
  21. BIN
      library/libs/x86/libavfilter.so
  22. BIN
      library/libs/x86/libavformat.so
  23. BIN
      library/libs/x86/libavresample.so
  24. BIN
      library/libs/x86/libavutil.so
  25. BIN
      library/libs/x86/libffmpeg.so
  26. BIN
      library/libs/x86/libswresample.so
  27. BIN
      library/libs/x86/libswscale.so
  28. 14
      library/src/main/cpp/ffmpeg/cmdutils.c
  29. 2
      library/src/main/cpp/include/libavutil/parseutils.h

@ -32,5 +32,6 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(path: ':library') implementation project(path: ':library')
// implementation 'com.github.xch168:ffmpeg-invoker:0.0.1'
} }

@ -21,25 +21,25 @@ HOST_PLATFORM="darwin-x86_64"
TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin" TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
ENABLED_ENCODERS=(h264 png) ENABLED_ENCODERS=(h264 png)
ENABLED_DECODERS=(h264 png) ENABLED_DECODERS=(h264 mpeg4 png)
ENABLED_MUXERS=(h264 mp4 3gp webm matroska avi image2) ENABLED_MUXERS=(h264 mp4 3gp webm matroska avi image2)
ENABLED_DEMUXERS=(webm matroska concat) ENABLED_DEMUXERS=(webm matroska concat)
ENABLED_PROTOCOLS=(file) ENABLED_PROTOCOLS=(file)
ENABLED_FILTERS=(scale)
COMMON_OPTIONS=" COMMON_OPTIONS="
--target-os=android --target-os=android
--disable-static --enable-static
--enable-shared --disable-shared
--disable-doc --disable-doc
--disable-everything
--disable-programs --disable-programs
--disable-protocols
--disable-parsers
--disable-avdevice --disable-avdevice
--disable-postproc --disable-postproc
--disable-symver --disable-symver
--enable-swscale --disable-debug
--enable-avformat
--enable-avfilter
--enable-avresample
--enable-swresample
" "
for encoder in "${ENABLED_ENCODERS[@]}" for encoder in "${ENABLED_ENCODERS[@]}"
@ -62,9 +62,13 @@ for protocol in "${ENABLED_PROTOCOLS[@]}"
do do
COMMON_OPTIONS="${COMMON_OPTIONS} --enable-protocol=${protocol}" COMMON_OPTIONS="${COMMON_OPTIONS} --enable-protocol=${protocol}"
done done
for filter in "${ENABLED_FILTERS[@]}"
do
COMMON_OPTIONS="${COMMON_OPTIONS} --enable-filter=${filter}"
done
cd "${FFMPEG_EXT_PATH}" cd "${FFMPEG_PATH}"
(git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg) # (git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg)
cd ffmpeg cd ffmpeg
git checkout release/4.2 git checkout release/4.2
@ -73,15 +77,37 @@ git checkout release/4.2
--prefix=android-libs/armeabi-v7a \ --prefix=android-libs/armeabi-v7a \
--arch=arm \ --arch=arm \
--cpu=armv7-a \ --cpu=armv7-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-" \ --cross-prefix="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-" \
--nm="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-nm" \ --nm="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-nm" \
--strip="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-strip" \ --cc="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-clang" \
--ar="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-ar" \
--extra-cflags="-march=armv7-a -mfloat-abi=softfp" \ --extra-cflags="-march=armv7-a -mfloat-abi=softfp" \
--extra-ldflags="-Wl,--fix-cortex-a8" \ --extra-ldflags="-Wl,--fix-cortex-a8" \
--extra-ldexeflags=-pie \ --extra-ldexeflags=-pie \
${COMMON_OPTIONS} ${COMMON_OPTIONS}
make -j4 make -j4
make install make install
SYSROOT="${NDK_PATH}/platforms/android-16/arch-arm"
PREFIX="$(pwd)/android-libs/armeabi-v7a"
# 打包
${TOOLCHAIN_PREFIX}/arm-linux-androideabi-ld \
-rpath-link=$SYSROOT/usr/lib \
-L$SYSROOT/usr/lib \
-L$PREFIX/lib \
-soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \
$PREFIX/libffmpeg.so \
libavcodec/libavcodec.a \
libavfilter/libavfilter.a \
libavformat/libavformat.a \
libavutil/libavutil.a \
libswresample/libswresample.a \
libswscale/libswscale.a \
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker \
${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc/arm-linux-androideabi/4.9.x/libgcc_real.a \
${TOOLCHAIN_PREFIX}/arm-linux-androideabi-strip $PREFIX/libffmpeg.so
make clean make clean
# arm64-v8a # arm64-v8a
@ -89,13 +115,35 @@ make clean
--prefix=android-libs/arm64-v8a \ --prefix=android-libs/arm64-v8a \
--arch=aarch64 \ --arch=aarch64 \
--cpu=armv8-a \ --cpu=armv8-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-" \ --cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android-" \
--nm="${TOOLCHAIN_PREFIX}/aarch64-linux-android-nm" \ --nm="${TOOLCHAIN_PREFIX}/aarch64-linux-android-nm" \
--strip="${TOOLCHAIN_PREFIX}/aarch64-linux-android-strip" \ --cc="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-clang" \
--ar="${TOOLCHAIN_PREFIX}/aarch64-linux-android-ar" \
--extra-ldexeflags=-pie \ --extra-ldexeflags=-pie \
${COMMON_OPTIONS} ${COMMON_OPTIONS}
make -j4 make -j8
make install make install
SYSROOT="${NDK_PATH}/platforms/android-21/arch-arm64"
PREFIX="$(pwd)/android-libs/arm64-v8a"
# 打包
${TOOLCHAIN_PREFIX}/aarch64-linux-android-ld \
-rpath-link=$SYSROOT/usr/lib \
-L$SYSROOT/usr/lib \
-L$PREFIX/lib \
-soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \
$PREFIX/libffmpeg.so \
libavcodec/libavcodec.a \
libavfilter/libavfilter.a \
libavformat/libavformat.a \
libavutil/libavutil.a \
libswresample/libswresample.a \
libswscale/libswscale.a \
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker \
${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc/aarch64-linux-android/4.9.x/libgcc_real.a \
${TOOLCHAIN_PREFIX}/aarch64-linux-android-strip $PREFIX/libffmpeg.so
make clean make clean
# x86 # x86
@ -103,12 +151,33 @@ make clean
--prefix=android-libs/x86 \ --prefix=android-libs/x86 \
--arch=x86 \ --arch=x86 \
--cpu=i686 \ --cpu=i686 \
--cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android16-" \ --cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android-" \
--nm="${TOOLCHAIN_PREFIX}/i686-linux-android-nm" \ --nm="${TOOLCHAIN_PREFIX}/i686-linux-android-nm" \
--strip="${TOOLCHAIN_PREFIX}/i686-linux-android-strip" \ --cc="${TOOLCHAIN_PREFIX}/i686-linux-android16-clang" \
--ar="${TOOLCHAIN_PREFIX}/i686-linux-android-ar" \
--extra-ldexeflags=-pie \ --extra-ldexeflags=-pie \
--disable-asm \ --disable-asm \
${COMMON_OPTIONS} ${COMMON_OPTIONS}
make -j4 make -j4
make install make install
SYSROOT="${NDK_PATH}/platforms/android-16/arch-x86"
PREFIX="$(pwd)/android-libs/x86"
${TOOLCHAIN_PREFIX}/i686-linux-android-ld \
-rpath-link=$SYSROOT/usr/lib \
-L$SYSROOT/usr/lib \
-L$PREFIX/lib \
-soname libffmpeg.so -shared -nostdlib -Bsymbolic --whole-archive --no-undefined -o \
$PREFIX/libffmpeg.so \
libavcodec/libavcodec.a \
libavfilter/libavfilter.a \
libavformat/libavformat.a \
libavutil/libavutil.a \
libswresample/libswresample.a \
libswscale/libswscale.a \
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker \
${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc/i686-linux-android/4.9.x/libgcc_real.a \
${TOOLCHAIN_PREFIX}/i686-linux-android-strip $PREFIX/libffmpeg.so
make clean make clean

@ -24,81 +24,22 @@ add_library( ffmpeg-invoker # 库名称
SHARED # SHARED #
${SRC}) # ) ${SRC}) # )
# libavcodec.so # libffmpeg.so
add_library( avcodec add_library( ffmpeg
SHARED SHARED
IMPORTED ) IMPORTED )
# libavcodec.so # libffmpeg.so
set_target_properties( avcodec set_target_properties( ffmpeg
PROPERTIES IMPORTED_LOCATION PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/libavcodec.so ) ${distribution_DIR}/libffmpeg.so )
# libavfilter.so
add_library( avfilter
SHARED
IMPORTED )
# libavfilter.so
set_target_properties( avfilter
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/libavfilter.so )
# libavformat.so
add_library( avformat
SHARED
IMPORTED )
# libavformat.so
set_target_properties( avformat
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/libavformat.so )
# libavresample.so
add_library( avresample
SHARED
IMPORTED )
# libavresample.so
set_target_properties( avresample
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/libavresample.so )
# libavutil.so
add_library( avutil
SHARED
IMPORTED )
# libavutil.so
set_target_properties( avutil
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/libavutil.so )
# libswresample.so
add_library( swresample
SHARED
IMPORTED )
# libswresample.so
set_target_properties( swresample
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/libswresample.so )
# libswscale.so
add_library( swscale
SHARED
IMPORTED )
# libswscale.so
set_target_properties( swscale
PROPERTIES IMPORTED_LOCATION
${distribution_DIR}/libswscale.so )
find_library( log-lib find_library( log-lib
log ) log )
target_link_libraries( ffmpeg-invoker target_link_libraries( ffmpeg-invoker
avcodec ffmpeg
avfilter
avformat
avresample
swresample
swscale
avutil
-landroid # native_window -landroid # native_window
-ljnigraphics # bitmap -ljnigraphics # bitmap
-lOpenSLES # openSLES -lOpenSLES # openSLES

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -556,7 +556,7 @@ int opt_default(void *optctx, const char *opt, const char *arg)
const char *p; const char *p;
const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
#if CONFIG_AVRESAMPLE #if CONFIG_AVRESAMPLE
const AVClass *rc = avresample_get_class(); // const AVClass *rc = avresample_get_class();
#endif #endif
#if CONFIG_SWSCALE #if CONFIG_SWSCALE
const AVClass *sc = sws_get_class(); const AVClass *sc = sws_get_class();
@ -628,11 +628,11 @@ int opt_default(void *optctx, const char *opt, const char *arg)
} }
#endif #endif
#if CONFIG_AVRESAMPLE #if CONFIG_AVRESAMPLE
if ((o=opt_find(&rc, opt, NULL, 0, // if ((o=opt_find(&rc, opt, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { // AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
av_dict_set(&resample_opts, opt, arg, FLAGS); // av_dict_set(&resample_opts, opt, arg, FLAGS);
consumed = 1; // consumed = 1;
} // }
#endif #endif
if (consumed) if (consumed)
@ -1137,7 +1137,7 @@ static void print_all_libs_info(int flags, int level)
PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); PRINT_LIB_INFO(avformat, AVFORMAT, flags, level);
PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level); // PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level);
PRINT_LIB_INFO(swscale, SWSCALE, flags, level); PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level); PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level);
PRINT_LIB_INFO(postproc, POSTPROC, flags, level); PRINT_LIB_INFO(postproc, POSTPROC, flags, level);

@ -19,7 +19,7 @@
#ifndef AVUTIL_PARSEUTILS_H #ifndef AVUTIL_PARSEUTILS_H
#define AVUTIL_PARSEUTILS_H #define AVUTIL_PARSEUTILS_H
#include "time.h" #include <time.h>
#include "rational.h" #include "rational.h"

Loading…
Cancel
Save