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'
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"
ENABLED_ENCODERS=(h264 png)
ENABLED_DECODERS=(h264 png)
ENABLED_DECODERS=(h264 mpeg4 png)
ENABLED_MUXERS=(h264 mp4 3gp webm matroska avi image2)
ENABLED_DEMUXERS=(webm matroska concat)
ENABLED_PROTOCOLS=(file)
ENABLED_FILTERS=(scale)
COMMON_OPTIONS="
--target-os=android
--disable-static
--enable-shared
--enable-static
--disable-shared
--disable-doc
--disable-everything
--disable-programs
--disable-protocols
--disable-parsers
--disable-avdevice
--disable-postproc
--disable-symver
--enable-swscale
--enable-avformat
--enable-avfilter
--enable-avresample
--enable-swresample
--disable-debug
"
for encoder in "${ENABLED_ENCODERS[@]}"
@ -62,9 +62,13 @@ for protocol in "${ENABLED_PROTOCOLS[@]}"
do
COMMON_OPTIONS="${COMMON_OPTIONS} --enable-protocol=${protocol}"
done
for filter in "${ENABLED_FILTERS[@]}"
do
COMMON_OPTIONS="${COMMON_OPTIONS} --enable-filter=${filter}"
done
cd "${FFMPEG_EXT_PATH}"
(git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg)
cd "${FFMPEG_PATH}"
# (git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg)
cd ffmpeg
git checkout release/4.2
@ -73,15 +77,37 @@ git checkout release/4.2
--prefix=android-libs/armeabi-v7a \
--arch=arm \
--cpu=armv7-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-" \
--cross-prefix="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-" \
--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-ldflags="-Wl,--fix-cortex-a8" \
--extra-ldexeflags=-pie \
${COMMON_OPTIONS}
make -j4
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
# arm64-v8a
@ -89,13 +115,35 @@ make clean
--prefix=android-libs/arm64-v8a \
--arch=aarch64 \
--cpu=armv8-a \
--cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-" \
--cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android-" \
--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 \
${COMMON_OPTIONS}
make -j4
make -j8
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
# x86
@ -103,12 +151,33 @@ make clean
--prefix=android-libs/x86 \
--arch=x86 \
--cpu=i686 \
--cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android16-" \
--cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android-" \
--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 \
--disable-asm \
${COMMON_OPTIONS}
make -j4
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

@ -24,81 +24,22 @@ add_library( ffmpeg-invoker # 库名称
SHARED #
${SRC}) # )
# libavcodec.so
add_library( avcodec
# libffmpeg.so
add_library( ffmpeg
SHARED
IMPORTED )
# libavcodec.so
set_target_properties( avcodec
# libffmpeg.so
set_target_properties( ffmpeg
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
log )
target_link_libraries( ffmpeg-invoker
avcodec
avfilter
avformat
avresample
swresample
swscale
avutil
ffmpeg
-landroid # native_window
-ljnigraphics # bitmap
-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 AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
#if CONFIG_AVRESAMPLE
const AVClass *rc = avresample_get_class();
// const AVClass *rc = avresample_get_class();
#endif
#if CONFIG_SWSCALE
const AVClass *sc = sws_get_class();
@ -628,11 +628,11 @@ int opt_default(void *optctx, const char *opt, const char *arg)
}
#endif
#if CONFIG_AVRESAMPLE
if ((o=opt_find(&rc, opt, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
av_dict_set(&resample_opts, opt, arg, FLAGS);
consumed = 1;
}
// if ((o=opt_find(&rc, opt, NULL, 0,
// AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
// av_dict_set(&resample_opts, opt, arg, FLAGS);
// consumed = 1;
// }
#endif
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(avdevice, AVDEVICE, 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(swresample, SWRESAMPLE, flags, level);
PRINT_LIB_INFO(postproc, POSTPROC, flags, level);

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

Loading…
Cancel
Save