说明
Ubuntu、Centos和Windows三平台的ffmpeg编译脚本,包含x264、x265、cuda加速、fdk-aac、opus以及openssl和rtmp库。
注释中有相关包的下载地址,需要先下载解压。
Windows需要安装msys2
,并在mingw64
下编译。
如果需要openssl
则把openssl的相关的脚本注释去掉,并在ffmpeg脚本参数--extra-libs
中添加上 -lssl -lcrypto
。
如果需要rtmp
库,则必须启用openssl
,并在ffmpeg脚本参数中启用--enable-rtmp
,现在是禁用状态。(其实没必要启用,只要支持flv
格式就推拉流)
ubuntu
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
| #!/bin/bash set -eo pipefail
export LOCAL_PATH=$(pwd) export BUILD_PATH=$LOCAL_PATH/ffmpeg_build_ubuntu 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-linux export BASE_PATH=/usr/bin export CC=$BASE_PATH/gcc export CXX=$BASE_PATH/g++ export AR=$BASE_PATH/ar export RANLIB=$BASE_PATH/ranlib export STRIP=$BASE_PATH/strip
sudo apt install -y build-essential cmake git autoconf automake pkgconf libtool
cd $LOCAL_PATH/yasm-1.3.0 rm -rf build && mkdir -p build && cd build ../configure --prefix="$BUILD_PATH" --host=$CHOST make -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/nasm-2.15.05 ./autogen.sh ./configure --prefix="$BUILD_PATH" make -j8 && 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 -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/nv-codec-headers-11.1.5.0 make -j8 PREFIX=$BUILD_PATH install cd $LOCAL_PATH
cd $LOCAL_PATH/x264-stable/ rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --host=$HOST \ --disable-cli \ --disable-asm \ --enable-shared=no \ --enable-static make -j8 && 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=OFF make -j8 && 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 -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/opus-1.3.1 rm -rf build && mkdir -p build && cd build ../configure \ --prefix="$BUILD_PATH" \ --host=$HOST \ --disable-shared make -j8 && 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=linux \ --cc=$CC \ --ranlib=$RANLIB \ --strip=$STRIP \ --pkg-config-flags="--static" \ --extra-cflags="-std=c11 -I$BUILD_PATH/include -I$BUILD_PATH/include/opus" \ --extra-ldflags="-L$BUILD_PATH/lib" \ --extra-libs="-latomic -lpthread -lm" \ --enable-static \ --disable-shared \ --disable-asm \ --disable-doc \ --disable-openssl \ --disable-libvpx \ --disable-libwebp \ --disable-lzma \ --disable-bzlib \ --enable-gpl \ --enable-nonfree \ --disable-librtmp \ --enable-libx264 \ --enable-libx265 \ --enable-libfdk-aac \ --enable-cuda --enable-cuvid --enable-nvenc \ --enable-libopus make -j8 && make install make clean cd $LOCAL_PATH
|
centos
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 193 194 195
| #!/bin/bash set -eo pipefail
export LOCAL_PATH=$(pwd) export BUILD_PATH=$LOCAL_PATH/ffmpeg_build_centos 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-linux export BASE_PATH=/opt/rh/devtoolset-9/root/usr/bin export CC=$BASE_PATH/gcc export CXX=$BASE_PATH/g++ export AR=$BASE_PATH/ar export RANLIB=$BASE_PATH/ranlib export STRIP=$BASE_PATH/strip
yum -y install centos-release-scl yum -y install llvm-toolset-7-cmake yum -y install devtoolset-9 yum -y install gcc gcc-c++ gdb make automake autoconf glibc-static libstdc++-static git libtool tcl tcl-devel
source /opt/rh/llvm-toolset-7/enable source /opt/rh/devtoolset-9/enable
cd $LOCAL_PATH/yasm-1.3.0 rm -rf build && mkdir -p build && cd build ../configure --prefix="$BUILD_PATH" --host=$CHOST make -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/nasm-2.15.05 ./autogen.sh ./configure --prefix="$BUILD_PATH" make -j8 && 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 -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/nv-codec-headers-11.1.5.0 make -j8 PREFIX=$BUILD_PATH install cd $LOCAL_PATH
cd $LOCAL_PATH/x264-stable/ rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --host=$HOST \ --disable-cli \ --disable-asm \ --enable-shared=no \ --enable-static make -j8 && 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=OFF make -j8 && 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 -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/opus-1.3.1 rm -rf build && mkdir -p build && cd build ../configure \ --prefix="$BUILD_PATH" \ --host=$HOST \ --disable-shared make -j8 && 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=linux \ --cc=$CC \ --ranlib=$RANLIB \ --strip=$STRIP \ --pkg-config-flags="--static" \ --extra-cflags="-std=c11 -I$BUILD_PATH/include -I$BUILD_PATH/include/opus" \ --extra-ldflags="-L$BUILD_PATH/lib" \ --extra-libs="-lpthread -lm" \ --enable-static \ --disable-shared \ --disable-asm \ --disable-doc \ --disable-openssl \ --disable-libvpx \ --disable-libwebp \ --disable-lzma \ --disable-bzlib \ --enable-gpl \ --enable-nonfree \ --disable-librtmp \ --enable-libx264 \ --enable-libx265 \ --enable-libfdk-aac \ --enable-cuda --enable-cuvid --enable-nvenc \ --enable-libopus \ make -j8 && make install make clean cd $LOCAL_PATH
|
windows
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
| #!/bin/bash set -eo pipefail
export LOCAL_PATH=$(pwd) export BUILD_PATH=$LOCAL_PATH/ffmpeg_build_msys2 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-w64-mingw32 export BASH_PATH=/mingw64/bin export CC=$BASH_PATH/gcc export CXX=$BASH_PATH/g++ export AR=$BASH_PATH/ar export RANLIB=$BASH_PATH/ranlib export STRIP=$BASH_PATH/strip
pacman -Syu --noconfirm pacman -Sy --noconfirm git mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmark mingw-w64-x86_64-diffutils mingw-w64-x86_64-autotools mingw-w64-x86_64-gdb mingw-w64-x86_64-nasm mingw-w64-x86_64-yasm
cd $LOCAL_PATH/yasm-1.3.0 rm -rf build && mkdir -p build && cd build ../configure --prefix="$BUILD_PATH" --host=$CHOST make -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/nasm-2.15.05 ./autogen.sh ./configure --prefix="$BUILD_PATH" make -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/zlib-1.2.11 sed -i 's/defined(_WIN32) || defined(__CYGWIN__)/defined(_WIN32)/g' gzguts.h rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --static make -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/nv-codec-headers-11.1.5.0 make -j8 PREFIX=$BUILD_PATH install cd $LOCAL_PATH
cd $LOCAL_PATH/x264-stable/ rm -rf build && mkdir -p build && cd build ../configure \ --prefix=$BUILD_PATH \ --host=$HOST \ --disable-cli \ --disable-asm \ --enable-shared=no \ --enable-static make -j8 && 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=OFF make -j8 && 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 -j8 && make install make clean cd $LOCAL_PATH
cd $LOCAL_PATH/opus-1.3.1 rm -rf build && mkdir -p build && cd build ../configure \ --prefix="$BUILD_PATH" \ --host=$HOST \ --disable-shared make -j8 && 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 \ --target-os=mingw32 \ --cc=$CC \ --ranlib=$RANLIB \ --strip=$STRIP \ --pkg-config-flags="--static" \ --extra-cflags="-std=c11 -I$BUILD_PATH/include -I$BUILD_PATH/include/opus" \ --extra-ldflags="-L$BUILD_PATH/lib" \ --extra-libs="-latomic -lpthread -lm" \ --disable-debug \ --enable-static \ --disable-shared \ --disable-asm \ --disable-doc \ --disable-openssl \ --disable-libvpx \ --disable-libwebp \ --disable-lzma \ --disable-bzlib \ --enable-gpl \ --enable-nonfree \ --disable-librtmp \ --enable-libx264 \ --enable-libx265 \ --enable-libfdk-aac \ --enable-cuda --enable-cuvid --enable-nvenc \ --enable-libopus \ make -j8 && make install make clean cd $LOCAL_PATH
|