1 | #!/bin/bash
|
---|
2 |
|
---|
3 | set -e
|
---|
4 |
|
---|
5 | function usage {
|
---|
6 | echo "Usage:"
|
---|
7 | echo "$0 platform ffmpeg_ver"
|
---|
8 | echo "platform: mipsel | mipsel_softfpu | armv7 | armv5t"
|
---|
9 | echo "ffmpeg_ver: 2.8.5 | 3.0.5 | 3.1.1 | 3.2.2"
|
---|
10 | exit 1
|
---|
11 | }
|
---|
12 |
|
---|
13 | if [ "$#" -ne 2 ];
|
---|
14 | then
|
---|
15 | usage
|
---|
16 | fi
|
---|
17 |
|
---|
18 | EPLATFORM=$1
|
---|
19 | FFMPEG_VERSION=$2
|
---|
20 |
|
---|
21 | if [ "$EPLATFORM" != "mipsel" -a "$EPLATFORM" != "mipsel_softfpu" -a "$EPLATFORM" != "armv7" -a "$EPLATFORM" != "armv5t" ];
|
---|
22 | then
|
---|
23 | echo "Please give supported platform (mipsel|mipsel_softfpu|armv7|armv5t) version!"
|
---|
24 | usage
|
---|
25 | fi
|
---|
26 |
|
---|
27 | if [ "$FFMPEG_VERSION" != "2.8.5" -a "$FFMPEG_VERSION" != "3.0.5" -a "$FFMPEG_VERSION" != "3.1.1" -a "$FFMPEG_VERSION" != "3.2.2" ];
|
---|
28 | then
|
---|
29 | echo "Please give supported ffmpeg (2.8.5|3.0.5|3.1.1|3.2.2) version!"
|
---|
30 | usage
|
---|
31 | fi
|
---|
32 |
|
---|
33 | case "$EPLATFORM" in
|
---|
34 | mipsel)
|
---|
35 | BASE_PATH="/mnt/new2/xspeedlx1/build-enviroment/builds/openatv/release/et4x00/tmp/sysroots/"
|
---|
36 | export TOOLCHAIN_NAME="mipsel-oe-linux"
|
---|
37 | export PATH=$BASE_PATH"i686-linux/usr/bin/mipsel-oe-linux/":$PATH
|
---|
38 | export SYSROOT=$BASE_PATH"et4x00"
|
---|
39 | CFLAGS=" -mel -mabi=32 -march=mips32 "
|
---|
40 | FFMPEG_CFLAGS=" -mel -mabi=32 -march=mips32 -I$SYSROOT/usr/include/libxml2/ "
|
---|
41 | FFMPEG_LDFLAGS=" -lssl -lcrypto -lxml2 "
|
---|
42 | ;;
|
---|
43 | mipsel_softfpu)
|
---|
44 | BASE_PATH="/mnt/new2/softFPU/openpli/build/tmp/sysroots/"
|
---|
45 | export TOOLCHAIN_NAME="mipsel-oe-linux"
|
---|
46 | export PATH=$BASE_PATH"i686-linux/usr/bin/mipsel-oe-linux/":$PATH
|
---|
47 | export SYSROOT=$BASE_PATH"et4x00"
|
---|
48 | CFLAGS=" -mel -mabi=32 -msoft-float -march=mips32 "
|
---|
49 | FFMPEG_CFLAGS=" -mel -mabi=32 -msoft-float -march=mips32 "
|
---|
50 | ;;
|
---|
51 | armv7)
|
---|
52 | if [ 0 -eq 1 ];
|
---|
53 | then
|
---|
54 | echo "ARMv7 toolchain openvuplus_3.0"
|
---|
55 | BASE_PATH="/mnt/new2/vusolo4k/openvuplus_3.0/build/vusolo4k/tmp/sysroots/"
|
---|
56 | export TOOLCHAIN_NAME="arm-oe-linux-gnueabi"
|
---|
57 | export PATH=$BASE_PATH"i686-linux/usr/bin/arm-oe-linux-gnueabi/":$PATH
|
---|
58 | export SYSROOT=$BASE_PATH"vusolo4k"
|
---|
59 | else
|
---|
60 | echo "ARMv7 toolchain openpli_4.0"
|
---|
61 | BASE_PATH="/mnt/new2/openpli_micro/openpli-oe-core/build/tmp/sysroots/"
|
---|
62 | export TOOLCHAIN_NAME="arm-oe-linux-gnueabi"
|
---|
63 | export PATH=$BASE_PATH"i686-linux/usr/bin/arm-oe-linux-gnueabi/":$PATH
|
---|
64 | export SYSROOT=$BASE_PATH"hd51"
|
---|
65 |
|
---|
66 | fi
|
---|
67 | CFLAGS=" -march=armv7-a -mfloat-abi=hard -mfpu=neon "
|
---|
68 | ;;
|
---|
69 | armv5t)
|
---|
70 | BASE_PATH="/mnt/new2/openatv2/build-enviroment/builds/openatv/release/cube/tmp/sysroots/"
|
---|
71 | export TOOLCHAIN_NAME="arm-oe-linux-gnueabi"
|
---|
72 | export PATH=$BASE_PATH"i686-linux/usr/bin/arm-oe-linux-gnueabi/":$PATH
|
---|
73 | export SYSROOT=$BASE_PATH"cube"
|
---|
74 | CFLAGS=" -mfloat-abi=softfp -mtune=cortex-a9 -mfpu=vfpv3-d16 "
|
---|
75 | ;;
|
---|
76 | *)
|
---|
77 | usage
|
---|
78 | exit 1
|
---|
79 | esac
|
---|
80 |
|
---|
81 | CFLAGS="$CFLAGS -pipe -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE "
|
---|
82 |
|
---|
83 | export CROSS_COMPILE=$TOOLCHAIN_NAME"-"
|
---|
84 |
|
---|
85 | SOURCE_FILES="main/exteplayer.c"
|
---|
86 | SOURCE_FILES+=" container/container.c"
|
---|
87 | SOURCE_FILES+=" container/container_ffmpeg.c"
|
---|
88 | SOURCE_FILES+=" manager/manager.c"
|
---|
89 | SOURCE_FILES+=" manager/audio.c"
|
---|
90 | SOURCE_FILES+=" manager/video.c"
|
---|
91 | SOURCE_FILES+=" manager/subtitle.c"
|
---|
92 | SOURCE_FILES+=" output/linuxdvb_mipsel.c"
|
---|
93 | SOURCE_FILES+=" output/output_subtitle.c"
|
---|
94 | SOURCE_FILES+=" output/output.c"
|
---|
95 |
|
---|
96 | SOURCE_FILES+=" output/writer/mipsel/writer.c"
|
---|
97 | SOURCE_FILES+=" output/writer/common/pes.c"
|
---|
98 | SOURCE_FILES+=" output/writer/common/misc.c"
|
---|
99 |
|
---|
100 | SOURCE_FILES+=" output/writer/mipsel/aac.c"
|
---|
101 | SOURCE_FILES+=" output/writer/mipsel/ac3.c"
|
---|
102 | SOURCE_FILES+=" output/writer/mipsel/mp3.c"
|
---|
103 | SOURCE_FILES+=" output/writer/mipsel/pcm.c"
|
---|
104 | SOURCE_FILES+=" output/writer/mipsel/lpcm.c"
|
---|
105 | SOURCE_FILES+=" output/writer/mipsel/dts.c"
|
---|
106 | SOURCE_FILES+=" output/writer/mipsel/amr.c"
|
---|
107 | SOURCE_FILES+=" output/writer/mipsel/wma.c"
|
---|
108 |
|
---|
109 | SOURCE_FILES+=" output/writer/mipsel/h265.c"
|
---|
110 | SOURCE_FILES+=" output/writer/mipsel/h264.c"
|
---|
111 | SOURCE_FILES+=" output/writer/mipsel/h263.c"
|
---|
112 | SOURCE_FILES+=" output/writer/mipsel/mpeg2.c"
|
---|
113 | SOURCE_FILES+=" output/writer/mipsel/mpeg4.c"
|
---|
114 | SOURCE_FILES+=" output/writer/mipsel/divx3.c"
|
---|
115 | SOURCE_FILES+=" output/writer/mipsel/vc1.c"
|
---|
116 | SOURCE_FILES+=" output/writer/mipsel/vp.c"
|
---|
117 | SOURCE_FILES+=" output/writer/mipsel/wmv.c"
|
---|
118 | SOURCE_FILES+=" playback/playback.c"
|
---|
119 |
|
---|
120 | SOURCE_FILES+=" external/ffmpeg/src/bitstream.c"
|
---|
121 | SOURCE_FILES+=" external/ffmpeg/src/latmenc.c"
|
---|
122 | SOURCE_FILES+=" external/ffmpeg/src/mpeg4audio.c"
|
---|
123 | CURR_PATH=$PWD
|
---|
124 |
|
---|
125 | EXTEPLAYER3_OUT_FILE=$CURR_PATH"/tmp/out/$EPLATFORM/exteplayer3_ffmpeg"$FFMPEG_VERSION
|
---|
126 |
|
---|
127 | function buildFFmpeg
|
---|
128 | {
|
---|
129 | FFMPEG_VERSION=$1
|
---|
130 | FFMPEG_BASE_PATH=$CURR_PATH"/tmp/ffmpeg/"
|
---|
131 | mkdir -p $FFMPEG_BASE_PATH"tmp/$EPLATFORM/"
|
---|
132 | FFMPEG_PATH=$FFMPEG_BASE_PATH"tmp/$EPLATFORM/ffmpeg-"$FFMPEG_VERSION
|
---|
133 | FFMPEG_PATCHES_PATH=$FFMPEG_BASE_PATH"patches/"$FFMPEG_VERSION"/"
|
---|
134 |
|
---|
135 | SOURCE_URL="http://ffmpeg.org/releases/ffmpeg-"$FFMPEG_VERSION".tar.gz"
|
---|
136 | OUT_FILE=$FFMPEG_BASE_PATH"tmp/ffmpeg-"$FFMPEG_VERSION".tar.gz"
|
---|
137 |
|
---|
138 | echo "FFMPEG PATH: $FFMPEG_PATH"
|
---|
139 |
|
---|
140 | if [ "true" == "$2" ] || [ ! -d $FFMPEG_PATH ];
|
---|
141 | then
|
---|
142 | if [ -d $FFMPEG_PATH ] && [ "true" == "$3" ];
|
---|
143 | then
|
---|
144 | rm -rf $FFMPEG_PATH
|
---|
145 | fi
|
---|
146 |
|
---|
147 | if [ ! -f $OUT_FILE ];
|
---|
148 | then
|
---|
149 | wget $SOURCE_URL -O $OUT_FILE
|
---|
150 | fi
|
---|
151 |
|
---|
152 | if [ ! -d $FFMPEG_PATH ];
|
---|
153 | then
|
---|
154 | tar -zxf $OUT_FILE -C $FFMPEG_BASE_PATH"tmp/$EPLATFORM/"
|
---|
155 |
|
---|
156 | if [ -d $FFMPEG_PATCHES_PATH ];
|
---|
157 | then
|
---|
158 | echo "Applay patches for ffmpeg version $FFMPEG_VERSION if any"
|
---|
159 | cd $FFMPEG_PATH
|
---|
160 | for i in "$FFMPEG_PATCHES_PATH"*.patch; do patch -p1 < $i; done
|
---|
161 | cd $CURR_PATH
|
---|
162 | fi
|
---|
163 | fi
|
---|
164 |
|
---|
165 | CONFIGURE_PATH=$FFMPEG_BASE_PATH"/scripts_$EPLATFORM/configure_"$FFMPEG_VERSION".sh"
|
---|
166 |
|
---|
167 | $FFMPEG_BASE_PATH"/scripts_$EPLATFORM/make.sh" $FFMPEG_PATH $CONFIGURE_PATH $SYSROOT "$FFMPEG_CFLAGS" "$FFMPEG_LDFLAGS"
|
---|
168 | else
|
---|
169 | #CONFIGURE_PATH=$FFMPEG_BASE_PATH"/scripts_$EPLATFORM/configure_"$FFMPEG_VERSION".sh"
|
---|
170 | #$FFMPEG_BASE_PATH"/scripts_$EPLATFORM/make.sh" $FFMPEG_PATH $CONFIGURE_PATH $SYSROOT
|
---|
171 | echo "Skip ffmpeg build"
|
---|
172 | fi
|
---|
173 | }
|
---|
174 |
|
---|
175 | # rebuild ffmpeg libs, force rebuild
|
---|
176 | buildFFmpeg $FFMPEG_VERSION "true" "true"
|
---|
177 |
|
---|
178 | rm -rf $EXTEPLAYER3_OUT_FILE
|
---|
179 |
|
---|
180 | echo "FFMPEG_PATH = $FFMPEG_PATH"
|
---|
181 | "$CROSS_COMPILE"gcc -Wimplicit-function-declaration -Wimplicit-int -fdata-sections -ffunction-sections -Wl,--gc-sections -Os $CFLAGS --sysroot=$SYSROOT $LDFLAGS $CPPFLAGS -I"$CURR_PATH"/include -I"$CURR_PATH"/external/ -I$FFMPEG_PATH/usr/include/ -L$FFMPEG_PATH/usr/lib/ $SOURCE_FILES -o $EXTEPLAYER3_OUT_FILE -Wfatal-errors -lpthread -lavformat -lavcodec -lavutil -lswresample
|
---|
182 | "$CROSS_COMPILE"strip -s $EXTEPLAYER3_OUT_FILE
|
---|
183 |
|
---|
184 | #exit 0
|
---|
185 |
|
---|
186 | FFMPEG_PACK_TMP=tmp/ffmpeg/tmp/ffmpeg"$FFMPEG_VERSION"_$EPLATFORM
|
---|
187 | rm -rf $FFMPEG_PACK_TMP
|
---|
188 | mkdir $FFMPEG_PACK_TMP
|
---|
189 |
|
---|
190 | cp -R tmp/ffmpeg/tmp/$EPLATFORM/ffmpeg-"$FFMPEG_VERSION"/usr $FFMPEG_PACK_TMP"/usr"
|
---|
191 | cd $FFMPEG_PACK_TMP
|
---|
192 | rm -Rf usr/include
|
---|
193 | rm -Rf usr/share
|
---|
194 | rm -Rf usr/lib/pk*
|
---|
195 | echo ">>>>>>>>>>>>>>>>>>>>>>"
|
---|
196 | tar -zcvf ../ffmpeg"$FFMPEG_VERSION"_$EPLATFORM.tar.gz usr
|
---|
197 |
|
---|
198 |
|
---|