forked from bilibili/ijkplayer
-
Notifications
You must be signed in to change notification settings - Fork 19
/
do-compile-ffmpeg.sh
executable file
·160 lines (131 loc) · 4.6 KB
/
do-compile-ffmpeg.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
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
#! /bin/sh
# This script is based on projects below
# https://github.com/kolyvan/kxmovie
# https://github.com/yixia/FFmpeg-Android
# http://git.videolan.org/?p=vlc-ports/android.git;a=summary
# https://github.com/kewlbear/FFmpeg-iOS-build-script/
#--------------------
echo "===================="
echo "[*] check host"
echo "===================="
set -e
#--------------------
# include
#--------------------
# common defines
FF_ARCH=$1
if [ -z "$FF_ARCH" ]; then
echo "You must specific an architecture 'armv7, armv7s, arm64, i386, x86_64, ...'.\n"
exit 1
fi
FF_BUILD_ROOT=`pwd`
FF_TAGET_OS="darwin"
# ffmpeg build params
export COMMON_FF_CFG_FLAGS=
source $FF_BUILD_ROOT/../tools/ffmpeg-common-profiles.sh
FFMPEG_CFG_FLAGS=
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --arch=$FF_ARCH"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --target-os=$FF_TAGET_OS"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-static"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-shared"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $COMMON_FF_CFG_FLAGS"
FFMPEG_EXTRA_CFLAGS=
# i386, x86_64
FFMPEG_CFG_FLAGS_SIMULATOR=
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-asm"
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-mmx"
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --assert-level=2"
# armv7, armv7s, arm64
FFMPEG_CFG_FLAGS_ARM=
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-pic"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-neon"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-optimizations"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-debug"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-small"
echo "build_root: $FF_BUILD_ROOT"
#--------------------
echo "===================="
echo "[*] check gas-preprocessor"
echo "===================="
FF_TOOLS_ROOT="$FF_BUILD_ROOT/../extra"
export PATH="$FF_TOOLS_ROOT/gas-preprocessor:$PATH"
echo "gasp: $FF_TOOLS_ROOT/gas-preprocessor/gas-preprocessor.pl"
#--------------------
echo "===================="
echo "[*] config arch $FF_ARCH"
echo "===================="
FF_BUILD_NAME="unknown"
FF_XCRUN_PLATFORM="iPhoneOS"
FF_XCRUN_SIMULATOR=
if [ "$FF_ARCH" == "i386" ]; then
FF_BUILD_NAME="ffmpeg-i386"
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_SIMULATOR="-mios-simulator-version-min=5.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" == "x86_64" ]; then
FF_BUILD_NAME="ffmpeg-x86_64"
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_SIMULATOR="-mios-simulator-version-min=7.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" == "armv7" ]; then
FF_BUILD_NAME="ffmpeg-armv7"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
# FFMPEG_CFG_CPU="--cpu=cortex-a8"
elif [ "$FF_ARCH" == "armv7s" ]; then
FF_BUILD_NAME="ffmpeg-armv7s"
FFMPEG_CFG_CPU="--cpu=swift"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
elif [ "$FF_ARCH" == "arm64" ]; then
FF_BUILD_NAME="ffmpeg-arm64"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
else
echo "unknown architecture $FF_ARCH";
exit 1
fi
echo "build_name: $FF_BUILD_NAME"
echo "platform: $FF_XCRUN_PLATFORM"
echo "simulator: $FF_XCRUN_SIMULATOR"
#--------------------
echo "===================="
echo "[*] make ios toolchain $FF_BUILD_NAME"
echo "===================="
FF_BUILD_SOURCE="$FF_BUILD_ROOT/$FF_BUILD_NAME"
FF_BUILD_PREFIX="$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --prefix=$FF_BUILD_PREFIX"
mkdir -p $FF_BUILD_PREFIX
echo "build_source: $FF_BUILD_SOURCE"
echo "build_prefix: $FF_BUILD_PREFIX"
#--------------------
echo "\n--------------------"
echo "[*] configurate ffmpeg"
echo "--------------------"
FF_XCRUN_SDK=`echo $FF_XCRUN_PLATFORM | tr '[:upper:]' '[:lower:]'`
FF_XCRUN_CC="xcrun -sdk $FF_XCRUN_SDK clang"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_CPU"
FFMPEG_CFLAGS=
FFMPEG_CFLAGS="$FFMPEG_CFLAGS -arch $FF_ARCH"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FF_XCRUN_SIMULATOR"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FFMPEG_EXTRA_CFLAGS"
FFMPEG_CXXFLAGS="$FFMPEG_CFLAGS"
FFMPEG_LDFLAGS="$FFMPEG_CFLAGS"
cd $FF_BUILD_SOURCE
if [ -f "./config.h" ]; then
echo 'reuse configure'
else
echo "config: $FFMPEG_CFG_FLAGS $FF_XCRUN_CC"
./configure \
$FFMPEG_CFG_FLAGS \
--cc="$FF_XCRUN_CC" \
$FFMPEG_CFG_CPU \
--extra-cflags="$FFMPEG_CFLAGS" \
--extra-cxxflags="$FFMPEG_CXXFLAGS" \
--extra-ldflags="$FFMPEG_LDFLAGS"
make clean
fi
#--------------------
echo "\n--------------------"
echo "[*] compile ffmpeg"
echo "--------------------"
cp config.* $FF_BUILD_PREFIX
make -j3
make install