-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_windows.sh
executable file
·112 lines (96 loc) · 3.65 KB
/
build_windows.sh
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
#!/bin/bash
compile_nv-codec-headers()
{
pushd third_party/nv-codec-headers
make PREFIX="./build" BINDDIR="./build"
[ $? != 0 ] && echo "compile nv-codec-headers failed!" && exit 1
make install PREFIX="./build" BINDDIR="./build"
popd
}
compile_x264()
{
pushd third_party/x264
./configure --enable-static --enable-pic --prefix="build" --host=x86_64-w64-mingw32 --cross-prefix=x86_64-w64-mingw32-
make -j$(nproc)
[ $? != 0 ] && echo "compile x264 failed!" && exit 1
make install
popd
}
compile_x265()
{
pushd third_party/x265/build/linux
# 支持10/12 bit编码(额外编译2个10/12bit的静态库)
mkdir -p 10bit 12bit
pushd 10bit
cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF \
-DCMAKE_TOOLCHAIN_FILE=../../../build/msys/toolchain-x86_64-w64-mingw32.cmake
make -j$(nproc)
[ $? != 0 ] && echo "compile x265 failed!" && exit 1
mv libx265.a libx265_main10.a
popd
pushd 12bit
cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON \
-DCMAKE_TOOLCHAIN_FILE=../../../build/msys/toolchain-x86_64-w64-mingw32.cmake
make -j$(nproc)
[ $? != 0 ] && echo "compile x265 failed!" && exit 1
mv libx265.a libx265_main12.a
popd
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="build" -DENABLE_SHARED=OFF \
-DEXTRA_LIB="x265_main10.a;x265_main12.a" \
-DEXTRA_LINK_FLAGS="-L./10bit -L./12bit" \
-DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" \
-DCMAKE_C_FLAGS="-static-libgcc -static-libstdc++" \
-DCMAKE_TOOLCHAIN_FILE=../../build/msys/toolchain-x86_64-w64-mingw32.cmake \
-DLINKED_10BIT=ON -DLINKED_12BIT=ON ../../source
make -j$(nproc)
[ $? != 0 ] && echo "compile x265 failed!" && exit 1
# 融合8/10/12bit的静态库为一个
mv libx265.a libx265_main.a
ar -M <<EOF
CREATE libx265.a
ADDLIB libx265_main.a
ADDLIB ./10bit/libx265_main10.a
ADDLIB ./12bit/libx265_main12.a
SAVE
END
EOF
sed '/Libs:/ s/$/ -lstdc++ -lgcc -lgcc -static/' -i x265.pc
make install
popd
}
# 编译第三方编解码库
compile_nv-codec-headers
compile_x264
compile_x265
# 定义路径及编译选项变量
NV_PATH="third_party/nv-codec-headers"
X264_PATH="third_party/x264"
X265_PATH="third_party/x265"
EXTRA_CFLAGS="-I/usr/local/cuda/include -I$NV_PATH/include -I$X264_PATH/build/include -I$X265_PATH/build/linux/build/include"
EXTRA_LDFLAGS="-L/usr/local/cuda/lib64 -L$X264_PATH/build/lib -L$X265_PATH/build/linux/build/lib"
# 依赖本地自定义的nv-codec-headers、libx264、libx265、libxavs、libxavs2、libdavs2、libmp3lame进行配置(以静态库方式链接)
PKG_CONFIG_PATH="$NV_PATH:$X264_PATH:$X265_PATH/build/linux/" \
./configure --prefix="build" --enable-shared \
--cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 \
--enable-gpl --enable-libx264 --enable-libx265 \
--enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-nonfree \
--extra-cflags="$EXTRA_CFLAGS" \
--extra-ldflags="$EXTRA_LDFLAGS" \
--pkg-config-flags="--static" --pkg-config=pkg-config
make -j$(nproc)
[ $? != 0 ] && echo "compile FFmpeg failed!" && exit 1
make install
# 打包
pushd build
mv ./bin/*.lib ./lib/
mkdir -p ffmpeg
cp -r include ffmpeg/
cp -r lib ffmpeg/
cp -r bin ffmpeg/
cp -r share ffmpeg/
tar zcf ffmpeg-windows-`date +%y%m%d`.tar.gz ffmpeg
rm -rf ffmpeg
popd
echo "************************************************************************************************"
echo "[FFmpeg压缩包] build/ffmpeg-windows-`date +%y%m%d`.tar.gz "
echo "************************************************************************************************"