Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoders-gpl flavor #2

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ jobs:
run: |
sudo chmod +x bundle_full.sh
./bundle_full.sh
- name: Bundle (encoders-gpl)
working-directory: ./buildscripts
run: |
sudo chmod +x bundle_encoders-gpl.sh
./bundle_encoders-gpl.sh
- uses: actions/[email protected]
with:
name: artifact
Expand Down
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
For the "default" and "full" flavors, the following license applies:

Copyright (c) 2016 Ilya Zhuravlev
Copyright (c) 2016 sfan5 <[email protected]>

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

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.

For the "encoders-gpl" flavor, the following license applies:

Copyright (C) 2023 Callum Moffat

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
5 changes: 5 additions & 0 deletions buildscripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ loadarch () {
export prefix_dir="$PWD/prefix/$prefix_name"
export native_dir="$PWD/../libmpv/src/main/jniLibs/$prefix_name"
export CC=$cc_triple-clang
if [[ "$1" == arm* ]]; then
export AS="$CC"
else
export AS="nasm"
fi
export CXX=$cc_triple-clang++
export AR=llvm-ar
export RANLIB=llvm-ranlib
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/bundle_default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ zip -r "default-armeabi-v7a.jar" lib/armeabi-v7a
zip -r "default-x86.jar" lib/x86
zip -r "default-x86_64.jar" lib/x86_64

mkdir ../../../../../../../../../../output
mkdir -p ../../../../../../../../../../output

cp *.jar ../../../../../../../../../../output

Expand Down
85 changes: 85 additions & 0 deletions buildscripts/bundle_encoders-gpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# --------------------------------------------------
set -euxo pipefail

export ENCODERS_GPL=1

if [ -d deps ]; then
sudo rm -r deps
fi
if [ -d prefix ]; then
sudo rm -r prefix
fi

./download.sh
./patch-encoders-gpl.sh

# --------------------------------------------------

rm scripts/ffmpeg.sh
cp flavors/encoders-gpl.sh scripts/ffmpeg.sh

# --------------------------------------------------

./build.sh

# --------------------------------------------------

cd deps/media-kit-android-helper

sudo chmod +x gradlew
./gradlew assembleRelease

unzip -o app/build/outputs/apk/release/app-release.apk -d app/build/outputs/apk/release

ln -sf "$(pwd)/app/build/outputs/apk/release/lib/arm64-v8a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/arm64-v8a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/armeabi-v7a/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/armeabi-v7a"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86"
ln -sf "$(pwd)/app/build/outputs/apk/release/lib/x86_64/libmediakitandroidhelper.so" "../../../libmpv/src/main/jniLibs/x86_64"

cd ../..

# --------------------------------------------------

cd deps/media_kit/media_kit_native_event_loop

flutter create --org com.alexmercerind --template plugin_ffi --platforms=android .

if ! grep -q android "pubspec.yaml"; then
printf " android:\n ffiPlugin: true\n" >> pubspec.yaml
fi

flutter pub get

cp -a ../../mpv/libmpv/. src/include/

cd example

flutter clean
flutter build apk --release

unzip -o build/app/outputs/apk/release/app-release.apk -d build/app/outputs/apk/release

cd build/app/outputs/apk/release/

# --------------------------------------------------

rm -r lib/*/libapp.so
rm -r lib/*/libflutter.so

zip -r "encoders-gpl-arm64-v8a.jar" lib/arm64-v8a
zip -r "encoders-gpl-armeabi-v7a.jar" lib/armeabi-v7a
zip -r "encoders-gpl-x86.jar" lib/x86
zip -r "encoders-gpl-x86_64.jar" lib/x86_64

mkdir -p ../../../../../../../../../../output

cp *.jar ../../../../../../../../../../output

md5sum *.jar

cd ../../../../../../../../..

# --------------------------------------------------

zip -r debug-symbols-encoders-gpl.zip prefix/*/lib
cp debug-symbols-encoders-gpl.zip ../output
2 changes: 1 addition & 1 deletion buildscripts/bundle_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ zip -r "full-armeabi-v7a.jar" lib/armeabi-v7a
zip -r "full-x86.jar" lib/x86
zip -r "full-x86_64.jar" lib/x86_64

mkdir ../../../../../../../../../../output
mkdir -p ../../../../../../../../../../output

cp *.jar ../../../../../../../../../../output

Expand Down
1 change: 0 additions & 1 deletion buildscripts/flavors/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ cpuflags=
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
\
--disable-gpl \
--disable-asm \
--disable-nonfree \
--enable-version3 \
--enable-static \
Expand Down
128 changes: 128 additions & 0 deletions buildscripts/flavors/encoders-gpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/bin/bash -e

. ../../include/depinfo.sh
. ../../include/path.sh

if [ "$1" == "build" ]; then
true
elif [ "$1" == "clean" ]; then
rm -rf _build$ndk_suffix
exit 0
else
exit 255
fi

mkdir -p _build$ndk_suffix
cd _build$ndk_suffix

cpu=armv7-a
[[ "$ndk_triple" == "aarch64"* ]] && cpu=armv8-a
[[ "$ndk_triple" == "x86_64"* ]] && cpu=generic
[[ "$ndk_triple" == "i686"* ]] && cpu="i686 --disable-asm"

cpuflags=
[[ "$ndk_triple" == "arm"* ]] && cpuflags="$cpuflags -mfpu=neon -mcpu=cortex-a8"

../configure \
--target-os=android --enable-cross-compile --cross-prefix=$ndk_triple- --ar=$AR --cc=$CC --ranlib=$RANLIB \
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config \
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
--pkg-config-flags="--static" \
\
--disable-nonfree \
--enable-version3 \
--enable-static \
--disable-shared \
--disable-vulkan \
--disable-iconv \
--disable-stripping \
--pkg-config-flags=--static \
\
--enable-decoders \
--enable-encoders \
--enable-libvorbis \
--enable-libvpx \
--enable-gpl \
--enable-libx264 \
--enable-muxers \
--enable-demuxers \
--enable-parsers \
\
--disable-protocols \
--disable-devices \
--disable-doc \
--disable-avdevice \
--disable-postproc \
--disable-programs \
--disable-gray \
--disable-swscale-alpha \
\
--enable-jni \
--enable-bsfs \
--enable-mediacodec \
\
--disable-dxva2 \
--disable-vaapi \
--disable-vdpau \
--disable-bzlib \
--disable-linux-perf \
--disable-videotoolbox \
--disable-audiotoolbox \
\
--enable-small \
--enable-hwaccels \
--enable-optimizations \
--enable-runtime-cpudetect \
\
--enable-mbedtls \
\
--enable-libdav1d \
\
--enable-libxml2 \
\
--enable-avutil \
--enable-avcodec \
--enable-avfilter \
--enable-avformat \
--enable-swscale \
--enable-swresample \
\
\
\
--enable-filters \
\
--enable-protocol=async \
--enable-protocol=cache \
--enable-protocol=crypto \
--enable-protocol=data \
--enable-protocol=ffrtmphttp \
--enable-protocol=file \
--enable-protocol=ftp \
--enable-protocol=hls \
--enable-protocol=http \
--enable-protocol=httpproxy \
--enable-protocol=https \
--enable-protocol=pipe \
--enable-protocol=rtmp \
--enable-protocol=rtmps \
--enable-protocol=rtmpt \
--enable-protocol=rtmpts \
--enable-protocol=rtp \
--enable-protocol=subfile \
--enable-protocol=tcp \
--enable-protocol=tls \
--enable-protocol=srt \
\
--enable-network \

make -j$cores
make DESTDIR="$prefix_dir" install

ln -sf "$prefix_dir"/lib/libswresample.so "$native_dir"
ln -sf "$prefix_dir"/lib/libpostproc.so "$native_dir"
ln -sf "$prefix_dir"/lib/libavutil.so "$native_dir"
ln -sf "$prefix_dir"/lib/libavcodec.so "$native_dir"
ln -sf "$prefix_dir"/lib/libavformat.so "$native_dir"
ln -sf "$prefix_dir"/lib/libswscale.so "$native_dir"
ln -sf "$prefix_dir"/lib/libavfilter.so "$native_dir"
ln -sf "$prefix_dir"/lib/libavdevice.so "$native_dir"
1 change: 0 additions & 1 deletion buildscripts/flavors/full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ cpuflags=
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
\
--disable-gpl \
--disable-asm \
--disable-nonfree \
--enable-version3 \
--enable-static \
Expand Down
16 changes: 14 additions & 2 deletions buildscripts/include/depinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,30 @@ v_dav1d=1.2.0
v_libxml2=2.10.3
v_ffmpeg=6.0
v_mpv=master
v_libogg=1.3.5
v_libvorbis=1.3.7
v_libvpx=1.13


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

dep_mbedtls=()
dep_dav1d=()
dep_ffmpeg=(mbedtls dav1d libxml2)
dep_libvorbis=(libogg)
if [ -n "$ENCODERS_GPL" ]; then
dep_ffmpeg=(mbedtls dav1d libxml2 libvorbis libvpx libx264)
else
dep_ffmpeg=(mbedtls dav1d libxml2)
fi
dep_freetype2=()
dep_fribidi=()
dep_harfbuzz=()
dep_libass=(freetype fribidi harfbuzz)
dep_lua=()
dep_shaderc=()
dep_mpv=(ffmpeg libass)
if [ -n "$ENCODERS_GPL" ]; then
dep_mpv=(ffmpeg libass fftools_ffi)
else
dep_mpv=(ffmpeg libass)
fi
15 changes: 15 additions & 0 deletions buildscripts/include/download-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ mkdir -p deps && cd deps
# libxml2
[ ! -d libxml2 ] && git clone --depth 1 --branch v$v_libxml2 --recursive https://gitlab.gnome.org/GNOME/libxml2.git libxml2

# libogg
[ ! -d libogg ] && $WGET https://github.com/xiph/ogg/releases/download/v${v_libogg}/libogg-${v_libogg}.tar.gz && tar -xf libogg-${v_libogg}.tar.gz && mv libogg-${v_libogg} libogg && rm libogg-${v_libogg}.tar.gz

# libvorbis
[ ! -d libvorbis ] && $WGET https://github.com/xiph/vorbis/releases/download/v${v_libvorbis}/libvorbis-${v_libvorbis}.tar.gz && tar -xf libvorbis-${v_libvorbis}.tar.gz && mv libvorbis-${v_libvorbis} libvorbis && rm libvorbis-${v_libvorbis}.tar.gz

# libvpx
[ ! -d libvpx ] && git clone --depth 1 --branch meson-$v_libvpx https://gitlab.freedesktop.org/gstreamer/meson-ports/libvpx.git

# libx264
[ ! -d libx264 ] && git clone --depth 1 https://code.videolan.org/videolan/x264.git --branch master libx264

# ffmpeg
[ ! -d ffmpeg ] && git clone --depth 1 --branch n$v_ffmpeg https://github.com/FFmpeg/FFmpeg.git ffmpeg

Expand Down Expand Up @@ -42,6 +54,9 @@ HEREDOC
# [ ! -d mpv ] && git clone --depth 1 --branch v$v_mpv https://github.com/mpv-player/mpv.git mpv
[ ! -d mpv ] && git clone --depth 1 --branch $v_mpv https://github.com/mpv-player/mpv.git mpv

# fftools_ffi
[ ! -d fftools_ffi ] && git clone --depth 1 --branch main https://github.com/moffatman/fftools-ffi.git fftools_ffi

# media-kit-android-helper
[ ! -d media-kit-android-helper ] && git clone --depth 1 --single-branch --branch main https://github.com/media-kit/media-kit-android-helper.git

Expand Down
21 changes: 21 additions & 0 deletions buildscripts/patch-encoders-gpl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -e

PATCHES=(patches-encoders-gpl/*)
ROOT=$(pwd)

for dep_path in "${PATCHES[@]}"; do
if [ -d "$dep_path" ]; then
patches=($dep_path/*)
dep=$(echo $dep_path |cut -d/ -f 2)
cd deps/$dep
echo Patching $dep
git reset --hard
for patch in "${patches[@]}"; do
echo Applying $patch
git apply "$ROOT/$patch"
done
cd $ROOT
fi
done

exit 0
1 change: 1 addition & 0 deletions buildscripts/patches-encoders-gpl/ffmpeg
Loading
Loading