Skip to content

Commit 83487f4

Browse files
committed
add ijkffmpeg
1 parent 71dc662 commit 83487f4

File tree

5 files changed

+304
-0
lines changed

5 files changed

+304
-0
lines changed

.github/workflows/apple-android-common.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ on:
3737
- dav1d
3838
- dvdread
3939
- ffmpeg
40+
- ijkffmpeg
4041
- harfbuzz
4142
- fontconfig
4243
- freetype

.github/workflows/install-dependencies.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ case $LIB_NAME in
5353
./main.sh install -l 'openssl opus dav1d dvdread uavs3d smb2 bluray' -p $PLAT
5454
fi
5555
;;
56+
ijkffmpeg)
57+
if [[ $PLAT == all ]];then
58+
./main.sh install -l 'openssl' -p ios
59+
./main.sh install -l 'openssl' -p tvos
60+
./main.sh install -l 'openssl' -p macos
61+
./main.sh install -l 'openssl' -p android
62+
elif [[ $PLAT == apple ]];then
63+
./main.sh install -l 'openssl' -p ios
64+
./main.sh install -l 'openssl' -p tvos
65+
./main.sh install -l 'openssl' -p macos
66+
else
67+
./main.sh install -l 'openssl' -p $PLAT
68+
fi
69+
;;
5670
harfbuzz)
5771
if [[ $PLAT == all ]];then
5872
./main.sh install -l 'freetype' -p ios

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"crypto.h": "c"
4+
}
5+
}

do-compile/android/ijkffmpeg.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (C) 2021 Matt Reach<qianlongxu@gmail.com>
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# This script is based on projects below
19+
# https://github.com/bilibili/ijkplayer
20+
21+
set -e
22+
23+
error_handler() {
24+
echo "An error occurred!"
25+
tail -n20 ${MR_BUILD_SOURCE}/ffbuild/config.log
26+
}
27+
28+
trap 'error_handler' ERR
29+
30+
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
31+
cd "$THIS_DIR"
32+
33+
export COMMON_FF_CFG_FLAGS=
34+
# use ijk ffmpeg config options
35+
source $MR_SHELL_CONFIGS_DIR/ijk-ffmpeg-config/module.sh
36+
37+
FFMPEG_CFG_FLAGS=
38+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $COMMON_FF_CFG_FLAGS"
39+
40+
# Advanced options (experts only):
41+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-cross-compile"
42+
# --disable-symver may indicate a bug
43+
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-symver"
44+
45+
# Developer options (useful when working on FFmpeg itself):
46+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-stripping"
47+
48+
##
49+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --arch=$MR_FF_ARCH"
50+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --target-os=$MR_TAGET_OS"
51+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-static"
52+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-shared"
53+
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --pkg-config-flags=--static"
54+
FFMPEG_EXTRA_CFLAGS=
55+
56+
# i386, x86_64
57+
FFMPEG_CFG_FLAGS_SIMULATOR=
58+
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-asm"
59+
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-mmx"
60+
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --assert-level=2"
61+
62+
# armv7, armv7s, arm64
63+
FFMPEG_CFG_FLAGS_ARM=
64+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-pic"
65+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-neon"
66+
case "$MR_DEBUG" in
67+
debug)
68+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-optimizations"
69+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
70+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-small"
71+
;;
72+
*)
73+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-optimizations"
74+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
75+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-small"
76+
;;
77+
esac
78+
79+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --prefix=$MR_BUILD_PREFIX"
80+
81+
FFMPEG_CFLAGS="$MR_DEFAULT_CFLAGS"
82+
FFMPEG_LDFLAGS="$FFMPEG_CFLAGS"
83+
FFMPEG_DEP_LIBS=
84+
85+
# libavformat/tls_openssl.c:56:16: error: use of undeclared identifier 'CRYPTO_LOCK'; did you mean 'CRYPTO_free'?
86+
# if (mode & CRYPTO_LOCK)
87+
# ^~~~~~~~~~~
88+
# CRYPTO_free
89+
90+
pkg-config --libs openssl --silence-errors >/dev/null && enable_openssl=1
91+
92+
if [[ $enable_openssl ]];then
93+
echo "[✅] --enable-openssl : $(pkg-config --modversion openssl)"
94+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-openssl"
95+
else
96+
echo "[❌] --disable-openssl"
97+
fi
98+
99+
#--------------------
100+
echo "--------------------"
101+
echo "[*] configure"
102+
echo "----------------------"
103+
104+
if [ ! -d $MR_BUILD_SOURCE ]; then
105+
echo ""
106+
echo "!! ERROR"
107+
echo "!! Can not find FFmpeg directory for $FF_BUILD_NAME"
108+
echo "!! Run 'sh init-ios.sh' first"
109+
echo ""
110+
exit 1
111+
fi
112+
113+
cd $MR_BUILD_SOURCE
114+
if [ -f "./config.h" ]; then
115+
echo 'reuse configure'
116+
else
117+
echo
118+
echo "CC: $MR_TRIPLE_CC"
119+
echo "CFLAGS: $FFMPEG_CFLAGS"
120+
echo "LDFLAG:$FFMPEG_LDFLAGS"
121+
echo "DEP_LIBS: $FFMPEG_DEP_LIBS"
122+
echo "FF_CFG_FLAGS: $FFMPEG_CFG_FLAGS"
123+
echo
124+
125+
./configure \
126+
$FFMPEG_CFG_FLAGS \
127+
--cc=${MR_TRIPLE_CC} \
128+
--as=${MR_TRIPLE_CC} \
129+
--ld=${MR_TRIPLE_CC} \
130+
--ar=${MR_AR} \
131+
--nm=${MR_NM} \
132+
--strip=${MR_STRIP} \
133+
--ranlib=${MR_RANLIB} \
134+
--extra-cflags="$FFMPEG_CFLAGS" \
135+
--extra-cxxflags="$FFMPEG_CFLAGS" \
136+
--extra-ldflags="$FFMPEG_LDFLAGS $FFMPEG_DEP_LIBS"
137+
fi
138+
139+
#--------------------
140+
echo "--------------------"
141+
echo "[*] compile ffmpeg"
142+
echo "--------------------"
143+
144+
make -j$MR_HOST_NPROC >/dev/null
145+
cp config.* $MR_BUILD_PREFIX
146+
make install >/dev/null
147+
mkdir -p $MR_BUILD_PREFIX/include/libffmpeg
148+
cp -f config.h $MR_BUILD_PREFIX/include/libffmpeg/config.h

do-compile/apple/ijkffmpeg.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (C) 2021 Matt Reach<qianlongxu@gmail.com>
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# This script is based on projects below
19+
# https://github.com/bilibili/ijkplayer
20+
21+
set -e
22+
23+
error_handler() {
24+
echo "An error occurred!"
25+
tail -n20 ${MR_BUILD_SOURCE}/ffbuild/config.log
26+
}
27+
28+
trap 'error_handler' ERR
29+
30+
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
31+
cd "$THIS_DIR"
32+
33+
export COMMON_FF_CFG_FLAGS=
34+
# use ijk ffmpeg config options
35+
source $MR_SHELL_CONFIGS_DIR/ijk-ffmpeg-config/module.sh
36+
37+
FFMPEG_CFG_FLAGS=
38+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $COMMON_FF_CFG_FLAGS"
39+
40+
# Advanced options (experts only):
41+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-cross-compile"
42+
# --disable-symver may indicate a bug
43+
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-symver"
44+
45+
# Developer options (useful when working on FFmpeg itself):
46+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-stripping"
47+
48+
##
49+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --arch=$MR_FF_ARCH"
50+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --target-os=$MR_TAGET_OS"
51+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-static"
52+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-shared"
53+
FFMPEG_EXTRA_CFLAGS=
54+
55+
# i386, x86_64
56+
FFMPEG_CFG_FLAGS_SIMULATOR=
57+
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-asm"
58+
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-mmx"
59+
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --assert-level=2"
60+
61+
# armv7, armv7s, arm64
62+
FFMPEG_CFG_FLAGS_ARM=
63+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-pic"
64+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-neon"
65+
case "$MR_DEBUG" in
66+
debug)
67+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-optimizations"
68+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
69+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-small"
70+
;;
71+
*)
72+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-optimizations"
73+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
74+
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-small"
75+
;;
76+
esac
77+
78+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --prefix=$MR_BUILD_PREFIX"
79+
80+
FFMPEG_CFLAGS="$MR_DEFAULT_CFLAGS"
81+
FFMPEG_LDFLAGS="$FFMPEG_CFLAGS"
82+
FFMPEG_DEP_LIBS=
83+
84+
pkg-config --libs openssl --silence-errors >/dev/null && enable_openssl=1
85+
86+
if [[ $enable_openssl ]];then
87+
echo "[✅] --enable-openssl : $(pkg-config --modversion openssl)"
88+
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-nonfree --enable-openssl"
89+
else
90+
echo "[❌] --disable-openssl"
91+
fi
92+
93+
#--------------------
94+
echo "--------------------"
95+
echo "[*] configure"
96+
echo "----------------------"
97+
98+
if [ ! -d $MR_BUILD_SOURCE ]; then
99+
echo ""
100+
echo "!! ERROR"
101+
echo "!! Can not find FFmpeg directory for $FF_BUILD_NAME"
102+
echo "!! Run 'sh init-ios.sh' first"
103+
echo ""
104+
exit 1
105+
fi
106+
107+
cd $MR_BUILD_SOURCE
108+
if [ -f "./config.h" ]; then
109+
echo 'reuse configure'
110+
else
111+
echo
112+
echo "CC: $MR_CC"
113+
echo "CFLAGS: $C_FLAGS"
114+
echo "LDFLAG:$LDFLAGS"
115+
echo "FF_CFG_FLAGS: $FFMPEG_CFG_FLAGS"
116+
echo
117+
./configure \
118+
$FFMPEG_CFG_FLAGS \
119+
--cc="$MR_CC" \
120+
--as="perl ${MR_GAS_PERL} -arch ${MR_ARCH} -- $MR_CC" \
121+
--extra-cflags="$FFMPEG_CFLAGS" \
122+
--extra-cxxflags="$FFMPEG_CFLAGS" \
123+
--extra-ldflags="$FFMPEG_LDFLAGS $FFMPEG_DEP_LIBS"
124+
make clean
125+
fi
126+
127+
#--------------------
128+
echo "--------------------"
129+
echo "[*] compile ffmpeg"
130+
echo "--------------------"
131+
132+
make -j$MR_HOST_NPROC >/dev/null
133+
cp config.* $MR_BUILD_PREFIX
134+
make install >/dev/null
135+
mkdir -p $MR_BUILD_PREFIX/include/libffmpeg
136+
cp -f config.h $MR_BUILD_PREFIX/include/libffmpeg/config.h

0 commit comments

Comments
 (0)