Skip to content

Commit 3516bd6

Browse files
authored
Merge pull request #2 from moffatman/main
encoders-gpl flavor
2 parents 062a4ee + 4083716 commit 3516bd6

24 files changed

+537
-6
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ jobs:
5050
run: |
5151
sudo chmod +x bundle_full.sh
5252
./bundle_full.sh
53+
- name: Bundle (encoders-gpl)
54+
working-directory: ./buildscripts
55+
run: |
56+
sudo chmod +x bundle_encoders-gpl.sh
57+
./bundle_encoders-gpl.sh
5358
- uses: actions/upload-artifact@v3.1.2
5459
with:
5560
name: artifact

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
For the "default" and "full" flavors, the following license applies:
2+
13
Copyright (c) 2016 Ilya Zhuravlev
24
Copyright (c) 2016 sfan5 <sfan5@live.de>
35

@@ -6,3 +8,20 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
68
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
79

810
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11+
12+
For the "encoders-gpl" flavor, the following license applies:
13+
14+
Copyright (C) 2023 Callum Moffat
15+
16+
This program is free software: you can redistribute it and/or modify
17+
it under the terms of the GNU General Public License as published by
18+
the Free Software Foundation, either version 3 of the License, or
19+
(at your option) any later version.
20+
21+
This program is distributed in the hope that it will be useful,
22+
but WITHOUT ANY WARRANTY; without even the implied warranty of
23+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+
GNU General Public License for more details.
25+
26+
You should have received a copy of the GNU General Public License
27+
along with this program. If not, see <http://www.gnu.org/licenses/>.

buildscripts/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ loadarch () {
4646
export prefix_dir="$PWD/prefix/$prefix_name"
4747
export native_dir="$PWD/../libmpv/src/main/jniLibs/$prefix_name"
4848
export CC=$cc_triple-clang
49+
if [[ "$1" == arm* ]]; then
50+
export AS="$CC"
51+
else
52+
export AS="nasm"
53+
fi
4954
export CXX=$cc_triple-clang++
5055
export AR=llvm-ar
5156
export RANLIB=llvm-ranlib

buildscripts/bundle_default.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ zip -r "default-armeabi-v7a.jar" lib/armeabi-v7a
7070
zip -r "default-x86.jar" lib/x86
7171
zip -r "default-x86_64.jar" lib/x86_64
7272

73-
mkdir ../../../../../../../../../../output
73+
mkdir -p ../../../../../../../../../../output
7474

7575
cp *.jar ../../../../../../../../../../output
7676

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# --------------------------------------------------
2+
set -euxo pipefail
3+
4+
export ENCODERS_GPL=1
5+
6+
if [ -d deps ]; then
7+
sudo rm -r deps
8+
fi
9+
if [ -d prefix ]; then
10+
sudo rm -r prefix
11+
fi
12+
13+
./download.sh
14+
./patch-encoders-gpl.sh
15+
16+
# --------------------------------------------------
17+
18+
rm scripts/ffmpeg.sh
19+
cp flavors/encoders-gpl.sh scripts/ffmpeg.sh
20+
21+
# --------------------------------------------------
22+
23+
./build.sh
24+
25+
# --------------------------------------------------
26+
27+
cd deps/media-kit-android-helper
28+
29+
sudo chmod +x gradlew
30+
./gradlew assembleRelease
31+
32+
unzip -o app/build/outputs/apk/release/app-release.apk -d app/build/outputs/apk/release
33+
34+
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/arm64-v8a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/arm64-v8a"
35+
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/armeabi-v7a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/armeabi-v7a"
36+
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86"
37+
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86_64/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86_64"
38+
39+
cd ../..
40+
41+
# --------------------------------------------------
42+
43+
cd deps/media_kit/media_kit_native_event_loop
44+
45+
flutter create --org com.alexmercerind --template plugin_ffi --platforms=android .
46+
47+
if ! grep -q android "pubspec.yaml"; then
48+
printf " android:\n ffiPlugin: true\n" >> pubspec.yaml
49+
fi
50+
51+
flutter pub get
52+
53+
cp -a ../../mpv/libmpv/. src/include/
54+
55+
cd example
56+
57+
flutter clean
58+
flutter build apk --release
59+
60+
unzip -o build/app/outputs/apk/release/app-release.apk -d build/app/outputs/apk/release
61+
62+
cd build/app/outputs/apk/release/
63+
64+
# --------------------------------------------------
65+
66+
rm -r lib/*/libapp.so
67+
rm -r lib/*/libflutter.so
68+
69+
zip -r "encoders-gpl-arm64-v8a.jar" lib/arm64-v8a
70+
zip -r "encoders-gpl-armeabi-v7a.jar" lib/armeabi-v7a
71+
zip -r "encoders-gpl-x86.jar" lib/x86
72+
zip -r "encoders-gpl-x86_64.jar" lib/x86_64
73+
74+
mkdir -p ../../../../../../../../../../output
75+
76+
cp *.jar ../../../../../../../../../../output
77+
78+
md5sum *.jar
79+
80+
cd ../../../../../../../../..
81+
82+
# --------------------------------------------------
83+
84+
zip -r debug-symbols-encoders-gpl.zip prefix/*/lib
85+
cp debug-symbols-encoders-gpl.zip ../output

buildscripts/bundle_full.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ zip -r "full-armeabi-v7a.jar" lib/armeabi-v7a
7070
zip -r "full-x86.jar" lib/x86
7171
zip -r "full-x86_64.jar" lib/x86_64
7272

73-
mkdir ../../../../../../../../../../output
73+
mkdir -p ../../../../../../../../../../output
7474

7575
cp *.jar ../../../../../../../../../../output
7676

buildscripts/flavors/default.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ cpuflags=
2929
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
3030
\
3131
--disable-gpl \
32-
--disable-asm \
3332
--disable-nonfree \
3433
--enable-version3 \
3534
--enable-static \
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash -e
2+
3+
. ../../include/depinfo.sh
4+
. ../../include/path.sh
5+
6+
if [ "$1" == "build" ]; then
7+
true
8+
elif [ "$1" == "clean" ]; then
9+
rm -rf _build$ndk_suffix
10+
exit 0
11+
else
12+
exit 255
13+
fi
14+
15+
mkdir -p _build$ndk_suffix
16+
cd _build$ndk_suffix
17+
18+
cpu=armv7-a
19+
[[ "$ndk_triple" == "aarch64"* ]] && cpu=armv8-a
20+
[[ "$ndk_triple" == "x86_64"* ]] && cpu=generic
21+
[[ "$ndk_triple" == "i686"* ]] && cpu="i686 --disable-asm"
22+
23+
cpuflags=
24+
[[ "$ndk_triple" == "arm"* ]] && cpuflags="$cpuflags -mfpu=neon -mcpu=cortex-a8"
25+
26+
../configure \
27+
--target-os=android --enable-cross-compile --cross-prefix=$ndk_triple- --ar=$AR --cc=$CC --ranlib=$RANLIB \
28+
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config \
29+
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
30+
--pkg-config-flags="--static" \
31+
\
32+
--disable-nonfree \
33+
--enable-version3 \
34+
--enable-static \
35+
--disable-shared \
36+
--disable-vulkan \
37+
--disable-iconv \
38+
--disable-stripping \
39+
--pkg-config-flags=--static \
40+
\
41+
--enable-decoders \
42+
--enable-encoders \
43+
--enable-libvorbis \
44+
--enable-libvpx \
45+
--enable-gpl \
46+
--enable-libx264 \
47+
--enable-muxers \
48+
--enable-demuxers \
49+
--enable-parsers \
50+
\
51+
--disable-protocols \
52+
--disable-devices \
53+
--disable-doc \
54+
--disable-avdevice \
55+
--disable-postproc \
56+
--disable-programs \
57+
--disable-gray \
58+
--disable-swscale-alpha \
59+
\
60+
--enable-jni \
61+
--enable-bsfs \
62+
--enable-mediacodec \
63+
\
64+
--disable-dxva2 \
65+
--disable-vaapi \
66+
--disable-vdpau \
67+
--disable-bzlib \
68+
--disable-linux-perf \
69+
--disable-videotoolbox \
70+
--disable-audiotoolbox \
71+
\
72+
--enable-small \
73+
--enable-hwaccels \
74+
--enable-optimizations \
75+
--enable-runtime-cpudetect \
76+
\
77+
--enable-mbedtls \
78+
\
79+
--enable-libdav1d \
80+
\
81+
--enable-libxml2 \
82+
\
83+
--enable-avutil \
84+
--enable-avcodec \
85+
--enable-avfilter \
86+
--enable-avformat \
87+
--enable-swscale \
88+
--enable-swresample \
89+
\
90+
\
91+
\
92+
--enable-filters \
93+
\
94+
--enable-protocol=async \
95+
--enable-protocol=cache \
96+
--enable-protocol=crypto \
97+
--enable-protocol=data \
98+
--enable-protocol=ffrtmphttp \
99+
--enable-protocol=file \
100+
--enable-protocol=ftp \
101+
--enable-protocol=hls \
102+
--enable-protocol=http \
103+
--enable-protocol=httpproxy \
104+
--enable-protocol=https \
105+
--enable-protocol=pipe \
106+
--enable-protocol=rtmp \
107+
--enable-protocol=rtmps \
108+
--enable-protocol=rtmpt \
109+
--enable-protocol=rtmpts \
110+
--enable-protocol=rtp \
111+
--enable-protocol=subfile \
112+
--enable-protocol=tcp \
113+
--enable-protocol=tls \
114+
--enable-protocol=srt \
115+
\
116+
--enable-network \
117+
118+
make -j$cores
119+
make DESTDIR="$prefix_dir" install
120+
121+
ln -sf "$prefix_dir"/lib/libswresample.so "$native_dir"
122+
ln -sf "$prefix_dir"/lib/libpostproc.so "$native_dir"
123+
ln -sf "$prefix_dir"/lib/libavutil.so "$native_dir"
124+
ln -sf "$prefix_dir"/lib/libavcodec.so "$native_dir"
125+
ln -sf "$prefix_dir"/lib/libavformat.so "$native_dir"
126+
ln -sf "$prefix_dir"/lib/libswscale.so "$native_dir"
127+
ln -sf "$prefix_dir"/lib/libavfilter.so "$native_dir"
128+
ln -sf "$prefix_dir"/lib/libavdevice.so "$native_dir"

buildscripts/flavors/full.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ cpuflags=
2929
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
3030
\
3131
--disable-gpl \
32-
--disable-asm \
3332
--disable-nonfree \
3433
--enable-version3 \
3534
--enable-static \

buildscripts/include/depinfo.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,30 @@ v_dav1d=1.2.0
1515
v_libxml2=2.10.3
1616
v_ffmpeg=6.0
1717
v_mpv=master
18+
v_libogg=1.3.5
19+
v_libvorbis=1.3.7
20+
v_libvpx=1.13
1821

1922

2023
## Dependency tree
2124
# I would've used a dict but putting arrays in a dict is not a thing
2225

2326
dep_mbedtls=()
2427
dep_dav1d=()
25-
dep_ffmpeg=(mbedtls dav1d libxml2)
28+
dep_libvorbis=(libogg)
29+
if [ -n "$ENCODERS_GPL" ]; then
30+
dep_ffmpeg=(mbedtls dav1d libxml2 libvorbis libvpx libx264)
31+
else
32+
dep_ffmpeg=(mbedtls dav1d libxml2)
33+
fi
2634
dep_freetype2=()
2735
dep_fribidi=()
2836
dep_harfbuzz=()
2937
dep_libass=(freetype fribidi harfbuzz)
3038
dep_lua=()
3139
dep_shaderc=()
32-
dep_mpv=(ffmpeg libass)
40+
if [ -n "$ENCODERS_GPL" ]; then
41+
dep_mpv=(ffmpeg libass fftools_ffi)
42+
else
43+
dep_mpv=(ffmpeg libass)
44+
fi

0 commit comments

Comments
 (0)