/
build-h264-aac.sh
executable file
·140 lines (120 loc) · 4.26 KB
/
build-h264-aac.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
#!/bin/bash
#
# Author: Mathieu Virbel <mat@kivy.org>
#
# This script compile a special version of ffmpeg only supporting H264 + AAC
# decoding. You can use it if you want to play video into your app, and if you
# can control the initial encoding.
#
usage() {
echo "Usage:"
echo ""
echo " FFMPEG_ARCHS='x86 armv7a' $0"
echo ""
echo "The result will be stored in build/ffmpeg/{x86,armv7a}/"
echo "Available ARCHS: x86 armv7a"
echo ""
echo "Note: to be able to build armv7a, you need the ANDROIDNDK env variable set"
exit 1
}
if [ "X$FFMPEG_ARCHS" == "X" ]; then
usage
exit 1
fi
rm -rf build/ffmpeg
mkdir -p build/ffmpeg
cd ffmpeg
# Don't build any neon version for now
#for version in armv5te armv7a; do
for version in $FFMPEG_ARCHS; do
echo "==> build for $version"
DEST=../build/ffmpeg
FLAGS="--disable-avfilter --disable-everything"
FLAGS="$FLAGS --enable-parser=h264,aac --enable-decoder=h263,h264,aac"
FLAGS="$FLAGS --enable-protocol=file"
FLAGS="$FLAGS --enable-demuxer=sdp --enable-pic"
FLAGS="$FLAGS --enable-small --disable-avdevice"
FLAGS="$FLAGS --enable-avresample"
#FLAGS="$FLAGS --disable-pthreads"
FLAGS="$FLAGS --enable-hwaccels"
# fix to prevent libavcodec.a(deinterlace.o): relocation R_X86_64_PC32 against symbol
# `ff_pw_4' can not be used when making a shared object; recompile with -fPIC
# note: yeap, fPIC is already activated, but doesn't work when compiling shared python.
# some refs http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3,
# but no doc found to explain the real issue :/
FLAGS="$FLAGS --disable-asm"
# needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52
# /usr/bin/ld: failed to set dynamic section sizes: Bad value
FLAGS="$FLAGS --disable-symver"
# disable some unused algo
# note: "golomb" are the one used in our video test, so don't use --disable-golomb
# note: and for aac decoding: "rdft", "mdct", and "fft" are needed
FLAGS="$FLAGS --disable-dxva2 --disable-vdpau --disable-vaapi"
FLAGS="$FLAGS --disable-dct"
# disabled with ffmpeg 2.0
#FLAGS="$FLAGS --disable-huffman --disable-lpc --disable-aandct"
# disable binaries / doc
FLAGS="$FLAGS --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver"
FLAGS="$FLAGS --disable-doc"
# why it doesn't work ?
#FLAGS="$FLAGS --disable-network"
case "$version" in
x86)
EXTRA_CFLAGS=""
#EXTRA_LDFLAGS="-Wl,-Bsymbolic"
EXTRA_LDFLAGS=""
ABI="x86"
;;
neon)
echo "Arch neon is not supported yet"
exit 1
FLAGS="$ARM_FLAGS $FLAGS"
EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"
# Runtime choosing neon vs non-neon requires
# renamed files
ABI="armeabi-v7a"
;;
armv7a)
# in that case, we need ANDROIDNDK
if [ "X$ANDROIDNDK" == "X" ]; then
echo "ANDROIDNDK variable not set"
echo "You must set it to your Android NDK root directory"
exit 1
fi
#SYSROOT=$ANDROIDNDK/platforms/android-8/arch-arm
#TOOLCHAIN=`echo $ANDROIDNDK/toolchains/arm-linux-androideabi-4.7/prebuilt/*-x86*`
SYSROOT=$ANDROIDNDK/platforms/android-3/arch-arm
TOOLCHAIN=`echo $ANDROIDNDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86`
echo "==> toolchain is $TOOLCHAIN"
export PATH=$TOOLCHAIN/bin:$PATH
ARM_FLAGS="--target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm"
ARM_FLAGS="$ARM_FLAGS --sysroot=$SYSROOT"
#ARM_FLAGS="$ARM_FLAGS --soname-prefix=/data/data/com.bambuser.broadcaster/lib/"
FLAGS="$ARM_FLAGS $FLAGS"
FLAGS="$FLAGS --enable-neon"
#EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fPIC -DANDROID"
#EXTRA_CFLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -fPIC -DANDROID"
EXTRA_CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fPIC -DANDROID"
EXTRA_LDFLAGS=""
ABI="armeabi-v7a"
;;
*)
echo "Unknown platform $version"
exit 1
;;
esac
DEST="$DEST/$ABI"
FLAGS="$FLAGS --prefix=$DEST"
mkdir -p $DEST
echo $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" > $DEST/info.txt
make distclean
set -x
./configure $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" \
| tee $DEST/configuration.txt
set +x
[ $PIPESTATUS == 0 ] || exit 1
make clean
make -j4 || exit 1
make install || exit 1
done