|
| 1 | +#!/bin/bash |
| 2 | +# Recent change made ffmpeg2 not compatible with python-for-android yet. |
| 3 | +# Only h264+aac build are working. |
| 4 | + |
| 5 | +VERSION_ffmpeg2=${VERSION_ffmpeg2:-2.7.1} |
| 6 | +URL_ffmpeg2=http://ffmpeg.org/releases/ffmpeg-$VERSION_ffmpeg2.tar.bz2 |
| 7 | +DEPS_ffmpeg2=(sdl) |
| 8 | +MD5_ffmpeg2= |
| 9 | +BUILD_ffmpeg2=$BUILD_PATH/ffmpeg2/$(get_directory $URL_ffmpeg2) |
| 10 | +RECIPE_ffmpeg2=$RECIPES_PATH/ffmpeg2 |
| 11 | +ARCH_ffmpeg2=${ARCH_ffmpeg2:-armv7a} |
| 12 | + |
| 13 | +function prebuild_ffmpeg2() { |
| 14 | + true |
| 15 | +} |
| 16 | + |
| 17 | +function shouldbuild_ffmpeg2() { |
| 18 | + if [ -f "$BUILD_ffmpeg2/build/ffmpeg/armeabi-v7a/lib/libavcodec.so" ]; then |
| 19 | + DO_BUILD=0 |
| 20 | + fi |
| 21 | +} |
| 22 | + |
| 23 | +function build_ffmpeg2() { |
| 24 | + cd $BUILD_ffmpeg2 |
| 25 | + |
| 26 | + # build ffmpeg2 |
| 27 | + export NDK=$ANDROIDNDK |
| 28 | + push_arm |
| 29 | + |
| 30 | + # configure |
| 31 | + DEST=build/ffmpeg |
| 32 | + |
| 33 | + for version in $ARCH_ffmpeg2; do |
| 34 | + |
| 35 | + FLAGS="--disable-everything" |
| 36 | + FLAGS="$FLAGS --enable-parser=h264,aac" |
| 37 | + FLAGS="$FLAGS --enable-decoder=h263,h264,aac" |
| 38 | + FLAGS="$FLAGS --enable-filter=aresample,resample,crop" |
| 39 | + FLAGS="$FLAGS --enable-protocol=file,http" |
| 40 | + FLAGS="$FLAGS --enable-demuxer=sdp --enable-pic" |
| 41 | + FLAGS="$FLAGS --enable-small" |
| 42 | + FLAGS="$FLAGS --enable-hwaccels" |
| 43 | + FLAGS="$FLAGS --disable-static --enable-shared" |
| 44 | + # libpostproc is GPL: https://ffmpeg.org/pipermail/ffmpeg-user/2012-February/005162.html |
| 45 | + FLAGS="$FLAGS --enable-gpl" |
| 46 | + |
| 47 | + # needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52 |
| 48 | + # /usr/bin/ld: failed to set dynamic section sizes: Bad value |
| 49 | + FLAGS="$FLAGS --disable-symver" |
| 50 | + |
| 51 | + # disable some unused algo |
| 52 | + # note: "golomb" are the one used in our video test, so don't use --disable-golomb |
| 53 | + # note: and for aac decoding: "rdft", "mdct", and "fft" are needed |
| 54 | + FLAGS="$FLAGS --disable-dxva2 --disable-vdpau --disable-vaapi" |
| 55 | + FLAGS="$FLAGS --disable-dct" |
| 56 | + |
| 57 | + # disable binaries / doc |
| 58 | + FLAGS="$FLAGS --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver" |
| 59 | + FLAGS="$FLAGS --disable-doc" |
| 60 | + |
| 61 | + case "$version" in |
| 62 | + x86) |
| 63 | + |
| 64 | + EXTRA_CFLAGS="" |
| 65 | + #EXTRA_LDFLAGS="-Wl,-Bsymbolic" |
| 66 | + EXTRA_LDFLAGS="" |
| 67 | + ABI="x86" |
| 68 | + ;; |
| 69 | + armv7a) |
| 70 | + ARM_FLAGS="--target-os=android --cross-prefix=arm-linux-androideabi- --arch=arm" |
| 71 | + ARM_FLAGS="$ARM_FLAGS --sysroot=$NDKPLATFORM" |
| 72 | + FLAGS="$ARM_FLAGS $FLAGS" |
| 73 | + FLAGS="$FLAGS --enable-neon" |
| 74 | + EXTRA_CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fPIC -DANDROID" |
| 75 | + EXTRA_LDFLAGS="" |
| 76 | + ABI="armeabi-v7a" |
| 77 | + ;; |
| 78 | + *) |
| 79 | + echo "Unknown platform $version" |
| 80 | + exit 1 |
| 81 | + ;; |
| 82 | + esac |
| 83 | + DEST="$DEST/$ABI" |
| 84 | + FLAGS="$FLAGS --prefix=$DEST" |
| 85 | + |
| 86 | + mkdir -p $DEST |
| 87 | + make distclean |
| 88 | + try ./configure $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" |
| 89 | + make clean |
| 90 | + try make -j4 |
| 91 | + try make install |
| 92 | + |
| 93 | + done |
| 94 | + |
| 95 | + # install |
| 96 | + FFMPEG_LIB="$BUILD_ffmpeg2/build/ffmpeg/armeabi-v7a/lib" |
| 97 | + try cp -a "$FFMPEG_LIB/libavcodec.so" "$LIBS_PATH/libavcodec.so" |
| 98 | + try cp -a "$FFMPEG_LIB/libavdevice.so" "$LIBS_PATH/libavdevice.so" |
| 99 | + try cp -a "$FFMPEG_LIB/libavfilter.so" "$LIBS_PATH/libavfilter.so" |
| 100 | + try cp -a "$FFMPEG_LIB/libavformat.so" "$LIBS_PATH/libavformat.so" |
| 101 | + try cp -a "$FFMPEG_LIB/libavutil.so" "$LIBS_PATH/libavutil.so" |
| 102 | + try cp -a "$FFMPEG_LIB/libswscale.so" "$LIBS_PATH/libswscale.so" |
| 103 | + try cp -a "$FFMPEG_LIB/libswresample.so" "$LIBS_PATH/libswresample.so" |
| 104 | + try cp -a "$FFMPEG_LIB/libpostproc.so" "$LIBS_PATH/libpostproc.so" |
| 105 | + |
| 106 | + pop_arm |
| 107 | +} |
| 108 | + |
| 109 | +function postbuild_ffmpeg2() { |
| 110 | + true |
| 111 | +} |
0 commit comments