Blame view

trunk/auto/build_ffmpeg.sh 4.3 KB
winlin authored
1 2
#!/bin/bash
winlin authored
3 4
ff_src_dir="../../3rdparty"
winlin authored
5 6 7 8 9
# the jobs to make ffmpeg
if [[ "" -eq SRS_JOBS ]]; then 
    export SRS_JOBS="--jobs=1" 
fi
winlin authored
10 11 12 13 14 15 16
ff_current_dir=$(pwd -P)
ff_build_dir="${ff_current_dir}/_build"
ff_release_dir="${ff_current_dir}/_release"
echo "start to build the tools for transcode system:"
echo "current_dir: ${ff_current_dir}"
echo "build_dir: ${ff_build_dir}"
echo "release_dir: ${ff_release_dir}"
winlin authored
17
echo "SRS_JOBS: ${SRS_JOBS}"
winlin authored
18 19 20 21 22 23 24 25 26 27 28

mkdir -p ${ff_build_dir}
mkdir -p ${ff_release_dir}

# yasm for libx264
ff_yasm_bin=${ff_release_dir}/bin/yasm
if [[ -f ${ff_yasm_bin} ]]; then 
    echo "yasm is ok"
else
    echo "build yasm-1.2.0"
    cd $ff_current_dir &&
winlin authored
29
    rm -rf yasm-1.2.0 && unzip -q ${ff_src_dir}/yasm-1.2.0.zip &&
winlin authored
30
    cd yasm-1.2.0 && ./configure --prefix=${ff_release_dir} &&
winlin authored
31
    make && make install
winlin authored
32 33
    ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build yasm-1.2.0 failed"; exit 1; fi
fi
34 35
# add yasm to path, for x264 to use yasm directly.
# ffmpeg can specifies the yasm path when configure it.
36
export PATH=${PATH}:${ff_release_dir}/bin
winlin authored
37 38 39 40 41 42 43

# libaacplus
if [[ -f ${ff_release_dir}/lib/libaacplus.a ]]; then
    echo "libaacplus is ok"
else
    echo "build yasm-1.2.0"
    cd $ff_current_dir &&
winlin authored
44 45
    rm -rf libaacplus-2.0.2 && unzip -q ${ff_src_dir}/libaacplus-2.0.2.zip &&
    cd libaacplus-2.0.2 && cp ../${ff_src_dir}/libaacplus-patch-26410-800.zip src/26410-800.zip &&
winlin authored
46
    bash autogen.sh && ./configure --prefix=${ff_release_dir} --enable-static && make && make install
winlin authored
47 48 49 50 51 52 53 54 55
    ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build libaacplus-2.0.2 failed"; exit 1; fi
fi

# lame-3.99
if [[ -f ${ff_release_dir}/lib/libmp3lame.a ]]; then
    echo "libmp3lame is ok"
else
    echo "build lame-3.99.5"
    cd $ff_current_dir &&
winlin authored
56
    rm -rf lame-3.99.5 && unzip -q ${ff_src_dir}/lame-3.99.5.zip &&
winlin authored
57
    cd lame-3.99.5 && ./configure --prefix=${ff_release_dir} --enable-static && make ${SRS_JOBS} && make install
winlin authored
58 59 60
    ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build lame-3.99.5 failed"; exit 1; fi
fi
61 62 63 64 65 66 67 68 69 70 71
# speex-1.2rc1
if [[ -f ${ff_release_dir}/lib/libspeex.a ]]; then
    echo "libspeex is ok"
else
    echo "build speex-1.2rc1"
    cd $ff_current_dir &&
    rm -rf speex-1.2rc1 && unzip -q ${ff_src_dir}/speex-1.2rc1.zip &&
    cd speex-1.2rc1 && ./configure --prefix=${ff_release_dir} --enable-static && make ${SRS_JOBS} && make install
    ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build speex-1.2rc1 failed"; exit 1; fi
fi
winlin authored
72 73 74 75 76 77
# x264 core.138
if [[ -f ${ff_release_dir}/lib/libx264.a ]]; then
    echo "x264 is ok"
else
    echo "build x264"
    cd $ff_current_dir &&
winlin authored
78
    rm -rf x264-snapshot-20131129-2245-stable && unzip -q ${ff_src_dir}/x264-snapshot-20131129-2245-stable.zip &&
79
    cd x264-snapshot-20131129-2245-stable && 
80 81 82
    ./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=8 \
        --enable-static --disable-avs  --disable-swscale  --disable-lavf \
        --disable-ffms  --disable-gpac && 
winlin authored
83
    make ${SRS_JOBS} && make install
winlin authored
84 85 86 87 88 89 90 91 92
    ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build x264 failed"; exit 1; fi
fi

# ffmpeg-2.1.1
if [[ -f ${ff_release_dir}/bin/ffmpeg ]]; then
    echo "ffmpeg-2.1.1 is ok"
else
    echo "build ffmpeg-2.1.1"
    cd $ff_current_dir &&
winlin authored
93
    rm -rf ffmpeg-2.1.1 && unzip -q ${ff_src_dir}/ffmpeg-2.1.1.zip &&
winlin authored
94 95 96 97 98 99 100 101 102 103 104
    echo "remove all so to force the ffmpeg to build in static" &&
    rm -f ${ff_release_dir}/lib/*.so* &&
    echo "export the dir to enable the build command canbe use." &&
    export ffmpeg_exported_release_dir=${ff_release_dir} &&
    cd ffmpeg-2.1.1 && 
    ./configure \
        --enable-gpl --enable-nonfree \
        --yasmexe=${ff_yasm_bin} \
        --prefix=${ff_release_dir} --cc= \
        --enable-static --disable-shared --disable-debug \
        --extra-cflags='-I${ffmpeg_exported_release_dir}/include' \
105
        --extra-ldflags='-L${ffmpeg_exported_release_dir}/lib -lm -ldl' \
winlin authored
106 107
        --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc \
        --enable-postproc --enable-bzlib --enable-zlib --enable-parsers \
108
        --enable-libx264 --enable-libmp3lame --enable-libaacplus --enable-libspeex \
winlin authored
109 110
        --enable-pthreads --extra-libs=-lpthread \
        --enable-encoders --enable-decoders --enable-avfilter --enable-muxers --enable-demuxers && 
winlin authored
111
    make ${SRS_JOBS} && make install
winlin authored
112
    ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build ffmpeg failed"; exit 1; fi
winlin authored
113
fi