Skip to content

Commit

Permalink
* Fix cppbuild.sh script to build properly FFmpeg from source on W…
Browse files Browse the repository at this point in the history
…indows
  • Loading branch information
saudet committed Jun 14, 2016
1 parent b431ff6 commit a1723f4
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Fix `cppbuild.sh` script to build properly FFmpeg from source on Windows
* Stop using Zeranoe FFmpeg builds, often not available for release versions ([issue #225](https://github.com/bytedeco/javacpp-presets/issues/225))
* Add `linux-ppc64le` to `cppbuild.sh` scripts of OpenCV, FFmpeg, Leptonica, and Tesseract

Expand Down
84 changes: 61 additions & 23 deletions ffmpeg/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ if [[ -z "$PLATFORM" ]]; then
exit
fi

DISABLE="--disable-w32threads --disable-iconv --disable-libxcb --disable-opencl --disable-sdl"
DISABLE="--disable-w32threads --disable-iconv --disable-libxcb --disable-opencl --disable-sdl --disable-bzlib --disable-lzma"
ENABLE="--enable-pthreads --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-runtime-cpudetect --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-openssl --enable-libopenh264 --enable-libx264 --enable-libx265 --enable-libvpx"

# minimal configuration to support MPEG-4 streams with H.264 and AAC as well as Motion JPEG
# DISABLE="--disable-w32threads --disable-iconv --disable-libxcb --disable-opencl --disable-sdl --disable-zlib --disable-everything"
# DISABLE="--disable-w32threads --disable-iconv --disable-libxcb --disable-opencl --disable-sdl --disable-bzlib --disable-lzma --disable-everything"
# ENABLE="--enable-pthreads --enable-shared --enable-runtime-cpudetect --enable-libopenh264 --enable-encoder=libopenh264 --enable-encoder=aac --enable-encoder=mjpeg --enable-decoder=h264 --enable-decoder=aac --enable-decoder=mjpeg --enable-parser=h264 --enable-parser=aac --enable-parser=mjpeg --enable-muxer=mp4 --enable-muxer=rtsp --enable-muxer=mjpeg --enable-demuxer=mov --enable-demuxer=rtsp --enable-demuxer=mjpeg --enable-protocol=file --enable-protocol=http --enable-protocol=rtp --enable-protocol=rtmp"

ZLIB=zlib-1.2.8
LAME=lame-3.99.5
SPEEX=speex-1.2rc2
OPENCORE_AMR=opencore-amr-0.1.3
Expand All @@ -22,6 +23,7 @@ OPENH264_VERSION=1.5.0
X265=x265_1.9
VPX_VERSION=v1.5.0
FFMPEG_VERSION=3.0.2
download http://zlib.net/$ZLIB.tar.gz $ZLIB.tar.gz
download http://downloads.sourceforge.net/project/lame/lame/3.99/$LAME.tar.gz $LAME.tar.gz
download http://downloads.xiph.org/releases/speex/$SPEEX.tar.gz $SPEEX.tar.gz
download http://sourceforge.net/projects/opencore-amr/files/opencore-amr/$OPENCORE_AMR.tar.gz/download $OPENCORE_AMR.tar.gz
Expand All @@ -35,6 +37,7 @@ download http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 ffmpeg-$FFMPE
mkdir -p $PLATFORM
cd $PLATFORM
INSTALL_PATH=`pwd`
tar -xzvf ../$ZLIB.tar.gz
tar -xzvf ../$LAME.tar.gz
tar -xzvf ../$SPEEX.tar.gz
tar -xzvf ../$OPENCORE_AMR.tar.gz
Expand All @@ -60,7 +63,11 @@ case $PLATFORM in
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-nostdlib -Wl,--fix-cortex-a8 -z text"
export LIBS="-lgcc -ldl -lz -lm -lc"
cd $LAME
cd $ZLIB
./configure --prefix=$INSTALL_PATH --static --uname=arm-linux
make -j $MAKEJ
make install
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=arm-linux
make -j $MAKEJ
make install
Expand Down Expand Up @@ -113,7 +120,11 @@ case $PLATFORM in
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-nostdlib -z text"
export LIBS="-lgcc -ldl -lz -lm -lc"
cd $LAME
cd $ZLIB
./configure --prefix=$INSTALL_PATH --static --uname=i686-linux
make -j $MAKEJ
make install
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=i686-linux
make -j $MAKEJ
make install
Expand Down Expand Up @@ -155,7 +166,11 @@ case $PLATFORM in
;;

linux-x86)
cd $LAME
cd $ZLIB
CC="gcc -m32 -fPIC" ./configure --prefix=$INSTALL_PATH --static
make -j $MAKEJ
make install
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=i686-linux CFLAGS="-m32 -msse2"
make -j $MAKEJ
make install
Expand Down Expand Up @@ -193,7 +208,11 @@ case $PLATFORM in
;;

linux-x86_64)
cd $LAME
cd $ZLIB
CC="gcc -m64 -fPIC" ./configure --prefix=$INSTALL_PATH --static
make -j $MAKEJ
make install
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=x86_64-linux CFLAGS="-m64"
make -j $MAKEJ
make install
Expand Down Expand Up @@ -231,45 +250,56 @@ case $PLATFORM in
;;

linux-armhf)
cd $LAME
CFLAGS="-march=armv6 -marm -mfpu=vfp -mfloat-abi=hard" CXXFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CPPFLAGS="-march=armv6 -marm -mfpu=vfp -mfloat-abi=hard" ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=arm-linux-gnueabihf
export CFLAGS="-march=armv6 -marm -mfpu=vfp -mfloat-abi=hard"
export CXXFLAGS="$CFLAGS"
export CPPFLAGS="$CFLAGS"
cd $ZLIB
CC="arm-linux-gnueabihf-gcc -fPIC" ./configure --prefix=$INSTALL_PATH --static
make -j $MAKEJ
make install
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=arm-linux-gnueabihf
make -j $MAKEJ
make install
cd ../$SPEEX
CFLAGS="-march=armv6 -marm -mfpu=vfp -mfloat-abi=hard" CXXFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CPPFLAGS="-march=armv6 -marm -mfpu=vfp -mfloat-abi=hard" ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=arm-linux-gnueabihf
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=arm-linux-gnueabihf
make -j $MAKEJ
make install
cd ../$OPENCORE_AMR
CFLAGS="-march=armv6 -marm -mfpu=vfp -mfloat-abi=hard" CXXFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CPPFLAGS="-march=armv6 -marm -mfpu=vfp -mfloat-abi=hard" ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=arm-linux-gnueabihf
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --host=arm-linux-gnueabihf
make -j $MAKEJ
make install
cd ../$OPENSSL
./Configure linux-armv4:arm-linux-gnueabihf-gcc -march=armv6 -mfpu=vfp -mfloat-abi=hard -fPIC no-shared --prefix=$INSTALL_PATH
make # fails with -j > 1
make install
cd ../openh264-$OPENH264_VERSION
CFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CXXFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CPPFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" make -j $MAKEJ DESTDIR=./ PREFIX=.. AR=arm-linux-gnueabihf-ar ARCH=armhf libraries install-static CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++
make -j $MAKEJ DESTDIR=./ PREFIX=.. AR=arm-linux-gnueabihf-ar ARCH=armhf libraries install-static CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++
cd ../$X264
CFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CXXFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CPPFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --disable-cli --host=arm-linux-gnueabihf --cross-prefix="arm-linux-gnueabihf-" --disable-asm
./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --disable-cli --host=arm-linux-gnueabihf --cross-prefix="arm-linux-gnueabihf-" --disable-asm
make -j $MAKEJ
make install
cd ../$X265
$CMAKE -DENABLE_CLI=OFF -DENABLE_SHARED=OFF -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_VERSION=1 -DCMAKE_SYSTEM_PROCESSOR=armv6 -DCMAKE_CXX_FLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" -DCMAKE_C_FLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++ -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_STRIP=/usr/bin/arm-linux-gnueabihf-strip -DCMAKE_FIND_ROOT_PATH=/usr/arm-linux-gnueabihf -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.. source
$CMAKE -DENABLE_CLI=OFF -DENABLE_SHARED=OFF -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_VERSION=1 -DCMAKE_SYSTEM_PROCESSOR=armv6 -DCMAKE_CXX_FLAGS="$CXXFLAGS" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++ -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_STRIP=/usr/bin/arm-linux-gnueabihf-strip -DCMAKE_FIND_ROOT_PATH=/usr/arm-linux-gnueabihf -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.. source
make -j $MAKEJ
make install
cd ../libvpx-$VPX_VERSION
CROSS=arm-linux-gnueabihf- CFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CXXFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CPPFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-examples --target=armv7-linux-gcc
CROSS=arm-linux-gnueabihf- ./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-examples --target=armv7-linux-gcc
make -j $MAKEJ
make install
cd ../ffmpeg-$FFMPEG_VERSION
[[ $ENABLE =~ "--enable-gpl" ]] && X11GRAB="--enable-x11grab" || X11GRAB=
PKG_CONFIG_PATH=../lib/pkgconfig/ CFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CXXFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" CPPFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=hard" ./configure --prefix=.. $DISABLE $ENABLE --cc="arm-linux-gnueabihf-gcc" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl" --enable-cross-compile --arch=armhf --target-os=linux --cross-prefix="arm-linux-gnueabihf-" --pkg-config-flags="--static" --pkg-config="pkg-config --static"
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --cc="arm-linux-gnueabihf-gcc" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl" --enable-cross-compile --arch=armhf --target-os=linux --cross-prefix="arm-linux-gnueabihf-" --pkg-config-flags="--static" --pkg-config="pkg-config --static"
make -j $MAKEJ
make install
;;

linux-ppc64le)
cd $LAME
cd $ZLIB
CC="gcc -m64 -fPIC" ./configure --prefix=$INSTALL_PATH --static
make -j $MAKEJ
make install
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --build=ppc64le-linux CFLAGS="-m64"
make -j $MAKEJ
make install
Expand Down Expand Up @@ -307,7 +337,11 @@ case $PLATFORM in
;;

macosx-*)
cd $LAME
cd $ZLIB
CC="clang -fPIC" ./configure --prefix=$INSTALL_PATH --static
make -j $MAKEJ
make install
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic
make -j $MAKEJ
make install
Expand Down Expand Up @@ -345,7 +379,9 @@ case $PLATFORM in
;;

windows-x86)
cd $LAME
cd $ZLIB
make -j $MAKEJ install -fwin32/Makefile.gcc BINARY_PATH=$INSTALL_PATH/bin/ INCLUDE_PATH=$INSTALL_PATH/include/ LIBRARY_PATH=$INSTALL_PATH/lib/
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --build=i686-w64-mingw32 CFLAGS="-m32 -msse2"
make -j $MAKEJ
make install
Expand All @@ -364,7 +400,7 @@ case $PLATFORM in
cd ../openh264-$OPENH264_VERSION
make -j $MAKEJ DESTDIR=./ PREFIX=.. AR=ar ARCH=x86 libraries install-static
cd ../$X264
./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --host=i686-w64-mingw32
./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --disable-win32thread --host=i686-w64-mingw32
make -j $MAKEJ
make install
cd ../$X265
Expand All @@ -377,13 +413,15 @@ case $PLATFORM in
make install
cd ../ffmpeg-$FFMPEG_VERSION
patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-windows.patch
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-indev=dshow --target-os=mingw32 --cc="gcc -m32" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic"
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-indev=dshow --target-os=mingw32 --cc="gcc -m32" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc -lgcc_eh -lpthread -Wl,-Bdynamic"
make -j $MAKEJ
make install
;;

windows-x86_64)
cd $LAME
cd $ZLIB
make -j $MAKEJ install -fwin32/Makefile.gcc BINARY_PATH=$INSTALL_PATH/bin/ INCLUDE_PATH=$INSTALL_PATH/include/ LIBRARY_PATH=$INSTALL_PATH/lib/
cd ../$LAME
./configure --prefix=$INSTALL_PATH --disable-shared --with-pic --build=x86_64-w64-mingw32 CFLAGS="-m64"
make -j $MAKEJ
make install
Expand All @@ -402,7 +440,7 @@ case $PLATFORM in
cd ../openh264-$OPENH264_VERSION
make -j $MAKEJ DESTDIR=./ PREFIX=.. AR=ar ARCH=x86_64 libraries install-static
cd ../$X264
./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --host=x86_64-w64-mingw32
./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-opencl --disable-win32thread --host=x86_64-w64-mingw32
make -j $MAKEJ
make install
cd ../$X265
Expand All @@ -415,7 +453,7 @@ case $PLATFORM in
make install
cd ../ffmpeg-$FFMPEG_VERSION
patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-windows.patch
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic"
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --extra-cflags="-I../include/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc -lgcc_eh -lpthread -Wl,-Bdynamic"
make -j $MAKEJ
make install
;;
Expand Down
43 changes: 37 additions & 6 deletions ffmpeg/ffmpeg-3.0.2-windows.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff -ruN ffmpeg-3.0/configure ffmpeg-3.0-windows/configure
--- ffmpeg-3.0/configure 2016-02-15 11:29:37.000000000 +0900
+++ ffmpeg-3.0-windows/configure 2016-02-20 23:31:02.433715264 +0900
@@ -5490,7 +5490,7 @@
diff -ruN ffmpeg-3.0.2/configure ffmpeg-3.0.2-windows/configure
--- ffmpeg-3.0.2/configure 2016-04-28 10:05:53.000000000 +0900
+++ ffmpeg-3.0.2-windows/configure 2016-06-14 12:41:10.282471200 +0900
@@ -5478,7 +5478,7 @@
enabled libopencv && { check_header opencv2/core/core_c.h &&
require_pkg_config opencv opencv2/core/core_c.h cvCreateImageHeader ||
require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader; }
Expand All @@ -10,7 +10,7 @@ diff -ruN ffmpeg-3.0/configure ffmpeg-3.0-windows/configure
enabled libopenjpeg && { check_lib openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
check_lib openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
@@ -5507,7 +5507,7 @@
@@ -5495,7 +5495,7 @@
enabled libsnappy && require snappy snappy-c.h snappy_compress -lsnappy
enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr && LIBSOXR="-lsoxr"
enabled libssh && require_pkg_config libssh libssh/sftp.h sftp_init
Expand All @@ -19,7 +19,38 @@ diff -ruN ffmpeg-3.0/configure ffmpeg-3.0-windows/configure
enabled libtesseract && require_pkg_config tesseract tesseract/capi.h TessBaseAPICreate
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame &&
@@ -5556,7 +5556,7 @@
@@ -5509,22 +5509,18 @@

enabled libvpx && {
enabled libvpx_vp8_decoder && {
- use_pkg_config "vpx >= 0.9.1" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx ||
check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
die "ERROR: libvpx decoder version must be >=0.9.1";
}
enabled libvpx_vp8_encoder && {
- use_pkg_config "vpx >= 0.9.7" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx ||
check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx ||
die "ERROR: libvpx encoder version must be >=0.9.7";
}
enabled libvpx_vp9_decoder && {
- use_pkg_config "vpx >= 1.3.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx ||
disable libvpx_vp9_decoder;
}
enabled libvpx_vp9_encoder && {
- use_pkg_config "vpx >= 1.3.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx ||
disable libvpx_vp9_encoder;
}
@@ -5537,14 +5533,14 @@
enabled libwebp && {
enabled libwebp_encoder && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
enabled libwebp_anim_encoder && { use_pkg_config "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit || disable libwebp_anim_encoder; } }
-enabled libx264 && { use_pkg_config x264 "stdint.h x264.h" x264_encoder_encode ||
+enabled libx264 && {
{ require libx264 x264.h x264_encoder_encode -lx264 &&
warn "using libx264 without pkg-config"; } } &&
{ check_cpp_condition x264.h "X264_BUILD >= 118" ||
die "ERROR: libx264 must be installed and version must be >= 0.118."; } &&
{ check_cpp_condition x264.h "X264_MPEG2" &&
enable libx262; }
Expand Down

0 comments on commit a1723f4

Please sign in to comment.