-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhm_ffmpeg.sh
executable file
·120 lines (101 loc) · 2.39 KB
/
hm_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
#!/bin/bash
set -e
source env.sh
ffmpeg_build=${build_dir}/ffmpeg
# default path of ffmpeg source code
ffmpeg_src=${DIR}/../ffmpeg
do_install=1
arch="arm64"
enable_opt=0
enable_x264=0
while [ $# -gt 0 ]; do
case $1 in
--help)
echo "Use --path to specify ffmpeg source directory"
echo "Use --install to install after build"
echo "Use --arch to specify cpu arch (arm, arm64)"
exit 1
;;
--path)
ffmpeg_src=$2
shift
;;
--arch)
arch=$2
shift
;;
--config_opt)
enable_opt=$2
echo "enable_opt $enable_opt"
shift
;;
--config_x264)
enable_x264=$2
echo "enable_x264 $enable_x264"
shift
;;
esac
shift
done
if ! [ -d ${ffmpeg_src} ]; then
echo "Directory $ffmpeg_src not found"
exit 1
fi
extra_config=" "
TOOLCHAIN=$OHOS_SDK_NATIVE/llvm
if [ "$arch" = "arm64" ] || [ "$arch" = "aarch64" ]; then
OHOS_ARCH="arm64-v8a"
TARGET=aarch64-unknown-linux-ohos
CPU=armv8-a
else
echo "Unknown arch $arch"
exit 1
fi
ffmpeg_build="${ffmpeg_build}-hm-${arch}"
install_dir="${install_dir}-hm-${arch}"
export AR=$TOOLCHAIN/bin/llvm-ar
export CC=$TOOLCHAIN/bin/$TARGET-clang
export CXX=$TOOLCHAIN/bin/$TARGET-clang++
export AR=$TOOLCHAIN/bin/llvm-ar
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export NM=$TOOLCHAIN/bin/llvm-nm
export STRINGS=$TOOLCHAIN/bin/llvm-strings
export STRIP=$TOOLCHAIN/bin/llvm-strip
mkdir -p $build_dir
pushd $build_dir
rm -Rf ${ffmpeg_build}
mkdir -p ${ffmpeg_build}
pushd ${ffmpeg_build}
if [ "$enable_opt" -eq 0 ]; then
extra_config="${extra_config} --disable-optimizations"
fi
$ffmpeg_src/configure \
--prefix=$install_dir \
--enable-nonfree \
--enable-gpl \
--enable-version3 \
--disable-doc \
--target-os=linux \
--cross-prefix=${TARGET}- \
--arch=$arch \
--cpu=$CPU \
--cc=$CC \
--cxx=$CXX \
--ld=$CXX \
--as=$CC \
--nm=$NM \
--ranlib=$RANLIB \
--strip=$STRIP \
--ar=$AR \
--enable-static --disable-shared \
--enable-pic \
--extra-libs="-lm" \
--extra-ldflags="-static-libstdc++" \
--enable-linux-perf \
${extra_config} \
make -j $(nproc)
if [ "$do_install" -eq 1 ]; then
make install
fi
popd # ${ffmpeg_build}
popd