说明
MacOS平台的ffmpeg编译脚本,包含x264、x265、fdk-aac、opus以及openssl和rtmp库。
注释中有相关包的下载地址,需要先下载解压。
如果需要openssl则把openssl的相关的脚本注释去掉,并在ffmpeg脚本参数–extra-libs中添加上 -lssl -lcrypto。
如果需要rtmp库,则必须启用openssl,并在ffmpeg脚本参数中启用–enable-rtmp,现在是禁用状态。(其实没必要启用,只要支持flv格式就推拉流)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
| #!/bin/bash set -eo pipefail
export LOCAL_PATH=$(pwd) export BUILD_PATH=$LOCAL_PATH/ffmpeg_build_macos export PKG_CONFIG_PATH=$BUILD_PATH/lib/pkgconfig export LD_LIBRARY_PATH=$BUILD_PATH/lib export CFLAGS=-I$BUILD_PATH/include export CPPFLAGS=-I$BUILD_PATH/include export LDFLAGS=-L$BUILD_PATH/lib export PATH=$BUILD_PATH/bin:$PATH
export CHOST=x86_64 export HOST=x86_64-apple-darwin export BASE_PATH=/usr/bin export CC=$BASE_PATH/clang export CXX=$BASE_PATH/clang++ export AR=$BASE_PATH/ar export RANLIB=$BASE_PATH/ranlib export STRIP=$BASE_PATH/strip
export CPU_CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
cd $LOCAL_PATH/yasm-1.3.0 rm -rf build && mkdir -p build && cd build ../configure --prefix="$BUILD_PATH" --host=$CHOST make -j${CPU_CORES} && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/nasm-2.15.05 ./autogen.sh ./configure --prefix="$BUILD_PATH" make -j${CPU_CORES} && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/zlib-1.2.11 rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --static make -j${CPU_CORES} && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/x264-stable/ rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --host=$HOST \ --enable-shared=no \ --enable-static \ make -j${CPU_CORES} && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/x265_3.5/source rm -rf build && mkdir -p build && cd build cmake .. -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$BUILD_PATH -DENABLE_SHARED=OFF -DENABLE_ASSEMBLY=ON make -j${CPU_CORES} && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/fdk-aac-2.0.2 ./autogen.sh rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --host=$HOST \ --enable-shared=no \ --enable-static make -j${CPU_CORES} && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/ffmpeg-4.4.1 rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --disable-debug \ --target-os=darwin \ --cc=$CC \ --ranlib=$RANLIB \ --strip=$STRIP \ --extra-cflags="-std=c11 -I$BUILD_PATH/include -I$BUILD_PATH/include/opus" \ --extra-cxxflags="-std=c++11" \ --extra-ldflags="-L$BUILD_PATH/lib" \ --extra-libs="-lpthread -lm -lc++" \ --host-cflags= \ --host-ldflags= \ --enable-static \ --disable-shared \ --disable-alsa \ --disable-doc \ --disable-openssl \ --disable-libvpx \ --disable-libwebp \ --disable-lzma \ --disable-bzlib \ --disable-xlib \ --disable-libxcb \ --disable-vaapi \ --disable-sndio \ --enable-gpl \ --enable-nonfree \ --disable-librtmp \ --enable-avresample \ --enable-libx264 \ --enable-libx265 \ --enable-libfdk-aac \ make -j${CPU_CORES} && make install make clean cd $LOCAL_PATH
|