Instantly share code, notes, and snippets.
Created
July 19, 2014 16:44
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save mekya/3d90041b7edea2ccaa65 to your computer and use it in GitHub Desktop.
javacpp-preset's ffmpeg build with fdk-aac for android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ -z "$PLATFORM" ]]; then | |
echo "This file is meant to be included by the parent cppbuild.sh script" | |
exit 1 | |
fi | |
if [[ $PLATFORM == windows* ]]; then | |
FFMPEG_VERSION=2.2.1 | |
download http://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-$FFMPEG_VERSION-win32-dev.7z ffmpeg-$FFMPEG_VERSION-win32-dev.7z | |
download http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-$FFMPEG_VERSION-win64-dev.7z ffmpeg-$FFMPEG_VERSION-win64-dev.7z | |
download http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-$FFMPEG_VERSION-win32-shared.7z ffmpeg-$FFMPEG_VERSION-win32-shared.7z | |
download http://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-$FFMPEG_VERSION-win64-shared.7z ffmpeg-$FFMPEG_VERSION-win64-shared.7z | |
download http://msinttypes.googlecode.com/files/msinttypes-r26.zip msinttypes-r26.zip | |
INSTALL_DIR=/C/MinGW/local | |
mkdir -p $INSTALL_DIR/include | |
unzip -o msinttypes-r26.zip -d $INSTALL_DIR/include | |
else | |
FFMPEG_VERSION=2.2.1 | |
cp /home/faraway/Downloads/fdk-aac-0.1.3.tar.gz ./ | |
download http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 ffmpeg-$FFMPEG_VERSION.tar.bz2 | |
download ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2 last_stable_x264.tar.bz2 | |
tar -xjvf ffmpeg-$FFMPEG_VERSION.tar.bz2 | |
mv ffmpeg-$FFMPEG_VERSION ffmpeg-$FFMPEG_VERSION-$PLATFORM | |
cd ffmpeg-$FFMPEG_VERSION-$PLATFORM | |
tar -xjvf ../last_stable_x264.tar.bz2 | |
X264=`echo x264-snapshot-*` | |
tar -xzf ../fdk-aac-0.1.3.tar.gz | |
FDK_AAC=`echo fdk*` | |
fi | |
case $PLATFORM in | |
android-arm) | |
cd $FDK_AAC | |
export CFLAGS="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" | |
export LDFLAGS="-Wl,--fix-cortex-a8" | |
export CC="arm-linux-androideabi-gcc --sysroot=$ANDROID_ROOT" | |
export CXX="arm-linux-androideabi-g++ --sysroot=$ANDROID_ROOT" | |
export PATH=/home/faraway/softwares/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin:$PATH | |
./configure --host=arm-linux-androideabi --with-sysroot="$ANDROID_ROOT" --enable-static --disable-shared --prefix="/tmp" | |
make -j4 | |
make install | |
cd ../$X264 | |
./configure --enable-static --enable-pic --disable-cli --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --host=arm-linux --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib -Wl,--fix-cortex-a8 -lgcc -ldl -lz -lm -lc" | |
make -j4 | |
cd .. | |
patch -Np1 < ../../ffmpeg-$FFMPEG_VERSION-android.patch | |
./configure --prefix="$ANDROID_NDK/../local/" --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-pthreads --enable-libfdk_aac --enable-nonfree --extra-cflags="-I/tmp/include" --extra-ldflags="-L/tmp/lib" --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --enable-cross-compile --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --target-os=linux --arch=arm --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib -Wl,--fix-cortex-a8" --extra-libs="-lfdk-aac -lgcc -ldl -lz -lm -lc" --disable-symver --disable-programs --libdir="$ANDROID_NDK/../local/lib/armeabi/" --shlibdir="$ANDROID_NDK/../local/lib/armeabi/" | |
make -j4 | |
make install | |
;; | |
android-x86) | |
cd $X264 | |
./configure --enable-static --enable-pic --disable-cli --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --host=i686-linux --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -mtune=atom -mssse3 -mfpmath=sse -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib -lgcc -ldl -lz -lm -lc" | |
make -j4 | |
cd .. | |
patch -Np1 < ../../ffmpeg-$FFMPEG_VERSION-android.patch | |
./configure --prefix="$ANDROID_NDK/../local/" --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --enable-cross-compile --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --target-os=linux --arch=atom --extra-cflags="-DANDROID -fPIC -ffunction-sections -funwind-tables -mssse3 -mfpmath=sse -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300" --extra-ldflags="-nostdlib" --extra-libs="-lgcc -ldl -lz -lm -lc" --disable-symver --disable-programs --libdir="$ANDROID_NDK/../local/lib/x86/" --shlibdir="$ANDROID_NDK/../local/lib/x86/" | |
make -j4 | |
make install | |
;; | |
linux-x86) | |
cd $X264 | |
./configure --enable-static --enable-pic --host=i686-linux | |
make -j4 | |
cd .. | |
./configure --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --cc="gcc -m32" --extra-ldflags="-ldl" --libdir=/usr/local/lib32/ --shlibdir=/usr/local/lib32/ | |
make -j4 | |
sudo make install | |
;; | |
linux-x86_64) | |
cd $X264 | |
./configure --enable-static --enable-pic | |
make -j4 | |
cd .. | |
./configure --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --extra-ldflags="-ldl" --libdir=/usr/local/lib64/ --shlibdir=/usr/local/lib64/ | |
make -j4 | |
sudo make install | |
;; | |
macosx-x86_64) | |
cd $X264 | |
./configure --enable-static --enable-pic | |
make -j4 | |
cd .. | |
./configure --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --enable-libx264 --extra-cflags="-I$X264" --extra-ldflags="-L$X264" --extra-ldflags="-Wl,-headerpad_max_install_names -ldl" | |
make -j4 | |
sudo make install | |
BADPATH=/usr/local/lib | |
LIBS="libavcodec.55.dylib libavdevice.55.dylib libavfilter.4.dylib libavformat.55.dylib libavutil.52.dylib libpostproc.52.dylib libswresample.0.dylib libswscale.2.dylib" | |
for f in $LIBS; do sudo install_name_tool $BADPATH/$f -id @rpath/$f \ | |
-add_rpath /usr/local/lib/ -add_rpath /opt/local/lib/ -add_rpath @loader_path/. \ | |
-change $BADPATH/libavcodec.55.dylib @rpath/libavcodec.55.dylib \ | |
-change $BADPATH/libavdevice.55.dylib @rpath/libavdevice.55.dylib \ | |
-change $BADPATH/libavfilter.4.dylib @rpath/libavfilter.4.dylib \ | |
-change $BADPATH/libavformat.55.dylib @rpath/libavformat.55.dylib \ | |
-change $BADPATH/libavutil.52.dylib @rpath/libavutil.52.dylib \ | |
-change $BADPATH/libpostproc.52.dylib @rpath/libpostproc.52.dylib \ | |
-change $BADPATH/libswresample.0.dylib @rpath/libswresample.0.dylib \ | |
-change $BADPATH/libswscale.2.dylib @rpath/libswscale.2.dylib; done | |
;; | |
windows-x86) | |
7za x -y ffmpeg-$FFMPEG_VERSION-win32-dev.7z | |
7za x -y ffmpeg-$FFMPEG_VERSION-win32-shared.7z | |
patch -Np1 -d ffmpeg-$FFMPEG_VERSION-win32-dev/ < ../ffmpeg-$FFMPEG_VERSION-win32-dev.patch | |
# http://ffmpeg.org/platform.html#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b | |
LIBS=(avcodec-55 avdevice-55 avfilter-4 avformat-55 avutil-52 postproc-52 swresample-0 swscale-2) | |
for LIB in ${LIBS[@]}; do | |
lib /def:ffmpeg-$FFMPEG_VERSION-win32-dev/lib/$LIB.def /out:ffmpeg-$FFMPEG_VERSION-win32-dev/lib/$LIB.lib /machine:x86 | |
done | |
rm -Rf ffmpeg-$FFMPEG_VERSION-win32-dev/lib32 | |
rm -Rf ffmpeg-$FFMPEG_VERSION-win32-shared/bin32 | |
mv ffmpeg-$FFMPEG_VERSION-win32-dev/lib ffmpeg-$FFMPEG_VERSION-win32-dev/lib32 | |
mv ffmpeg-$FFMPEG_VERSION-win32-shared/bin ffmpeg-$FFMPEG_VERSION-win32-shared/bin32 | |
cp -a ffmpeg-$FFMPEG_VERSION-win32-dev/* $INSTALL_DIR | |
cp -a ffmpeg-$FFMPEG_VERSION-win32-shared/* $INSTALL_DIR | |
;; | |
windows-x86_64) | |
7za x -y ffmpeg-$FFMPEG_VERSION-win64-dev.7z | |
7za x -y ffmpeg-$FFMPEG_VERSION-win64-shared.7z | |
patch -Np1 -d ffmpeg-$FFMPEG_VERSION-win64-dev/ < ../ffmpeg-$FFMPEG_VERSION-win64-dev.patch | |
# http://ffmpeg.org/platform.html#Linking-to-FFmpeg-with-Microsoft-Visual-C_002b_002b | |
LIBS=(avcodec-55 avdevice-55 avfilter-4 avformat-55 avutil-52 postproc-52 swresample-0 swscale-2) | |
for LIB in ${LIBS[@]}; do | |
lib /def:ffmpeg-$FFMPEG_VERSION-win64-dev/lib/$LIB.def /out:ffmpeg-$FFMPEG_VERSION-win64-dev/lib/$LIB.lib /machine:x64 | |
done | |
rm -Rf ffmpeg-$FFMPEG_VERSION-win64-dev/lib64 | |
rm -Rf ffmpeg-$FFMPEG_VERSION-win64-shared/bin64 | |
mv ffmpeg-$FFMPEG_VERSION-win64-dev/lib ffmpeg-$FFMPEG_VERSION-win64-dev/lib64 | |
mv ffmpeg-$FFMPEG_VERSION-win64-shared/bin ffmpeg-$FFMPEG_VERSION-win64-shared/bin64 | |
cp -a ffmpeg-$FFMPEG_VERSION-win64-dev/* $INSTALL_DIR | |
cp -a ffmpeg-$FFMPEG_VERSION-win64-shared/* $INSTALL_DIR | |
;; | |
*) | |
echo "Error: Platform \"$PLATFORM\" is not supported" | |
;; | |
esac | |
if [[ $PLATFORM != windows* ]]; then | |
cd .. | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment