winlin

add ffmpeg build script

  1 +#!/bin/bash
  2 +
  3 +ff_current_dir=$(pwd -P)
  4 +ff_build_dir="${ff_current_dir}/_build"
  5 +ff_release_dir="${ff_current_dir}/_release"
  6 +echo "start to build the tools for transcode system:"
  7 +echo "current_dir: ${ff_current_dir}"
  8 +echo "build_dir: ${ff_build_dir}"
  9 +echo "release_dir: ${ff_release_dir}"
  10 +
  11 +mkdir -p ${ff_build_dir}
  12 +mkdir -p ${ff_release_dir}
  13 +
  14 +# yasm for libx264
  15 +ff_yasm_bin=${ff_release_dir}/bin/yasm
  16 +if [[ -f ${ff_yasm_bin} ]]; then
  17 + echo "yasm is ok"
  18 +else
  19 + echo "build yasm-1.2.0"
  20 + cd $ff_current_dir &&
  21 + rm -rf yasm-1.2.0 && unzip -q ../../3rdparty/yasm-1.2.0.zip &&
  22 + cd yasm-1.2.0 && ./configure --prefix=${ff_release_dir} &&
  23 + make && make install
  24 + ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build yasm-1.2.0 failed"; exit 1; fi
  25 +fi
  26 +
  27 +# libaacplus
  28 +if [[ -f ${ff_release_dir}/lib/libaacplus.a ]]; then
  29 + echo "libaacplus is ok"
  30 +else
  31 + echo "build yasm-1.2.0"
  32 + cd $ff_current_dir &&
  33 + rm -rf libaacplus-2.0.2 && unzip -q ../../3rdparty/libaacplus-2.0.2.zip &&
  34 + cd libaacplus-2.0.2 && cp ../../../3rdparty/libaacplus-patch-26410-800.zip src/26410-800.zip &&
  35 + bash autogen.sh && ./configure --prefix=${ff_release_dir} --enable-static && make && make install
  36 + ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build libaacplus-2.0.2 failed"; exit 1; fi
  37 +fi
  38 +
  39 +# lame-3.99
  40 +if [[ -f ${ff_release_dir}/lib/libmp3lame.a ]]; then
  41 + echo "libmp3lame is ok"
  42 +else
  43 + echo "build lame-3.99.5"
  44 + cd $ff_current_dir &&
  45 + rm -rf lame-3.99.5 && unzip -q ../../3rdparty/lame-3.99.5.zip &&
  46 + cd lame-3.99.5 && ./configure --prefix=${ff_release_dir} --enable-static && make && make install
  47 + ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build lame-3.99.5 failed"; exit 1; fi
  48 +fi
  49 +
  50 +# x264 core.138
  51 +if [[ -f ${ff_release_dir}/lib/libx264.a ]]; then
  52 + echo "x264 is ok"
  53 +else
  54 + echo "build x264"
  55 + cd $ff_current_dir &&
  56 + rm -rf x264-snapshot-20131129-2245-stable && unzip -q ../../3rdparty/x264-snapshot-20131129-2245-stable.zip &&
  57 + cd x264-snapshot-20131129-2245-stable && ./configure --prefix=${ff_release_dir} --bit-depth=10 --enable-static && make && make install
  58 + ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build x264 failed"; exit 1; fi
  59 +fi
  60 +
  61 +# ffmpeg-2.1.1
  62 +if [[ -f ${ff_release_dir}/bin/ffmpeg ]]; then
  63 + echo "ffmpeg-2.1.1 is ok"
  64 +else
  65 + echo "build ffmpeg-2.1.1"
  66 + cd $ff_current_dir &&
  67 + rm -rf ffmpeg-2.1.1 && unzip -q ../../3rdparty/ffmpeg-2.1.1.zip &&
  68 + echo "remove all so to force the ffmpeg to build in static" &&
  69 + rm -f ${ff_release_dir}/lib/*.so* &&
  70 + echo "export the dir to enable the build command canbe use." &&
  71 + export ffmpeg_exported_release_dir=${ff_release_dir} &&
  72 + cd ffmpeg-2.1.1 &&
  73 + ./configure \
  74 + --enable-gpl --enable-nonfree \
  75 + --yasmexe=${ff_yasm_bin} \
  76 + --prefix=${ff_release_dir} --cc= \
  77 + --enable-static --disable-shared --disable-debug \
  78 + --extra-cflags='-I${ffmpeg_exported_release_dir}/include' \
  79 + --extra-ldflags='-L${ffmpeg_exported_release_dir}/lib -lm' \
  80 + --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc \
  81 + --enable-postproc --enable-bzlib --enable-zlib --enable-parsers \
  82 + --enable-libx264 --enable-libmp3lame --enable-libaacplus \
  83 + --enable-pthreads --extra-libs=-lpthread --enable-encoders --enable-decoders --enable-avfilter --enable-muxers --enable-demuxers &&
  84 + make && make install
  85 + ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build x264 failed"; exit 1; fi
  86 +fi