This commit is contained in:
Mark Qvist
2025-11-26 22:14:49 +01:00
parent e6a4ab919a
commit 6808620f0c
5 changed files with 1 additions and 221 deletions

View File

@@ -1,42 +0,0 @@
from pythonforandroid.recipe import PyProjectRecipe, Recipe
from os.path import join
class FFPyPlayerRecipe(PyProjectRecipe):
version = 'v4.5.2'
url = 'https://github.com/matham/ffpyplayer/archive/{version}.zip'
depends = ['python3', 'sdl2', 'ffmpeg']
patches = ["setup.py.patch"]
opt_depends = ['openssl', 'ffpyplayer_codecs']
def get_recipe_env(self, arch, with_flags_in_cc=True):
env = super().get_recipe_env(arch)
build_dir = Recipe.get_recipe('ffmpeg', self.ctx).get_build_dir(arch.arch)
env["FFMPEG_INCLUDE_DIR"] = join(build_dir, "include")
env["FFMPEG_LIB_DIR"] = join(build_dir, "lib")
env["SDL_INCLUDE_DIR"] = join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include')
env["SDL_LIB_DIR"] = join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)
env["USE_SDL2_MIXER"] = '1'
# ffpyplayer does not allow to pass more than one include dir for sdl2_mixer (and ATM is
# not needed), so we only pass the first one.
sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
env["SDL2_MIXER_INCLUDE_DIR"] = sdl2_mixer_recipe.get_include_dirs(arch)[0]
# NDKPLATFORM and LIBLINK are our switches for detecting Android platform, so can't be empty
# FIXME: We may want to introduce a cleaner approach to this?
env['NDKPLATFORM'] = "NOTNONE"
env['LIBLINK'] = 'NOTNONE'
# ffmpeg recipe enables GPL components only if ffpyplayer_codecs recipe used.
# Therefore we need to disable libpostproc if skipped.
if 'ffpyplayer_codecs' not in self.ctx.recipe_build_order:
env["CONFIG_POSTPROC"] = '0'
return env
recipe = FFPyPlayerRecipe()

View File

@@ -1,15 +0,0 @@
--- ffpyplayer/setup.py 2024-06-02 11:10:49.691183467 +0530
+++ ffpyplayer.mod/setup.py 2024-06-02 11:20:16.220966873 +0530
@@ -27,12 +27,6 @@
# This sets whether or not Cython gets added to setup_requires.
declare_cython = False
-if platform in ('ios', 'android'):
- # NEVER use or declare cython on these platforms
- print('Not using cython on %s' % platform)
- can_use_cython = False
-else:
- declare_cython = True
src_path = build_path = dirname(__file__)
print(f'Source/build path: {src_path}')

View File

@@ -1,152 +0,0 @@
from pythonforandroid.toolchain import Recipe, current_directory, shprint
from os.path import exists, join, realpath
import sh
class FFMpegRecipe(Recipe):
version = 'n4.3.1'
# Moved to github.com instead of ffmpeg.org to improve download speed
url = 'https://github.com/FFmpeg/FFmpeg/archive/{version}.zip'
depends = ['sdl2'] # Need this to build correct recipe order
opts_depends = ['openssl', 'ffpyplayer_codecs']
patches = ['patches/configure.patch']
def should_build(self, arch):
build_dir = self.get_build_dir(arch.arch)
return not exists(join(build_dir, 'lib', 'libavcodec.so'))
def prebuild_arch(self, arch):
self.apply_patches(arch)
def get_recipe_env(self, arch):
env = super().get_recipe_env(arch)
env['NDK'] = self.ctx.ndk_dir
return env
def build_arch(self, arch):
with current_directory(self.get_build_dir(arch.arch)):
env = arch.get_env()
# flags = ['--disable-everything']
flags = []
cflags = []
ldflags = []
if 'openssl' in self.ctx.recipe_build_order:
flags += [
'--enable-openssl',
'--enable-nonfree',
'--enable-protocol=https,tls_openssl',
]
build_dir = Recipe.get_recipe(
'openssl', self.ctx).get_build_dir(arch.arch)
cflags += ['-I' + build_dir + '/include/',
'-DOPENSSL_API_COMPAT=0x10002000L']
ldflags += ['-L' + build_dir]
if 'ffpyplayer_codecs' in self.ctx.recipe_build_order:
# Enable GPL
flags += ['--enable-gpl']
# libx264
flags += ['--enable-libx264']
build_dir = Recipe.get_recipe(
'libx264', self.ctx).get_build_dir(arch.arch)
cflags += ['-I' + build_dir + '/include/']
ldflags += ['-lx264', '-L' + build_dir + '/lib/']
# libshine
flags += ['--enable-libshine']
build_dir = Recipe.get_recipe('libshine', self.ctx).get_build_dir(arch.arch)
cflags += ['-I' + build_dir + '/include/']
ldflags += ['-lshine', '-L' + build_dir + '/lib/']
ldflags += ['-lm']
# libvpx
flags += ['--enable-libvpx']
build_dir = Recipe.get_recipe(
'libvpx', self.ctx).get_build_dir(arch.arch)
cflags += ['-I' + build_dir + '/include/']
ldflags += ['-lvpx', '-L' + build_dir + '/lib/']
# Enable all codecs:
flags += [
'--enable-parsers',
'--enable-decoders',
'--enable-encoders',
'--enable-muxers',
'--enable-demuxers',
]
else:
# Enable codecs only for .mp4:
flags += [
'--enable-parser=aac,ac3,h261,h264,mpegaudio,mpeg4video,mpegvideo,vc1',
'--enable-decoder=aac,h264,mpeg4,mpegvideo',
'--enable-muxer=h264,mov,mp4,mpeg2video',
'--enable-demuxer=aac,h264,m4v,mov,mpegvideo,vc1,rtsp',
]
# needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52
# /usr/bin/ld: failed to set dynamic section sizes: Bad value
flags += [
'--disable-symver',
]
# disable binaries / doc
flags += [
# '--disable-programs',
'--disable-doc',
]
# other flags:
flags += [
'--enable-filter=aresample,resample,crop,adelay,volume,scale',
'--enable-protocol=file,http,hls,udp,tcp',
'--enable-small',
'--enable-hwaccels',
'--enable-pic',
'--disable-static',
'--disable-debug',
'--enable-shared',
]
if 'arm64' in arch.arch:
arch_flag = 'aarch64'
elif 'x86' in arch.arch:
arch_flag = 'x86'
flags += ['--disable-asm']
else:
arch_flag = 'arm'
# android:
flags += [
'--target-os=android',
'--enable-cross-compile',
'--cross-prefix={}-'.format(arch.target),
'--arch={}'.format(arch_flag),
'--strip={}'.format(self.ctx.ndk.llvm_strip),
'--sysroot={}'.format(self.ctx.ndk.sysroot),
'--enable-neon',
'--prefix={}'.format(realpath('.')),
]
if arch_flag == 'arm':
cflags += [
'-mfpu=vfpv3-d16',
'-mfloat-abi=softfp',
'-fPIC',
]
env['CFLAGS'] += ' ' + ' '.join(cflags)
env['LDFLAGS'] += ' ' + ' '.join(ldflags)
configure = sh.Command('./configure')
shprint(configure, *flags, _env=env)
shprint(sh.make, '-j4', _env=env)
shprint(sh.make, 'install', _env=env)
# copy libs:
sh.cp('-a', sh.glob('./lib/lib*.so'),
self.ctx.get_libs_dir(arch.arch))
recipe = FFMpegRecipe()

View File

@@ -1,11 +0,0 @@
--- ./configure 2020-10-11 19:12:16.759760904 +0200
+++ ./configure.patch 2020-10-11 19:15:49.059533563 +0200
@@ -6361,7 +6361,7 @@
enabled librsvg && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
enabled librtmp && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket
enabled librubberband && require_pkg_config librubberband "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append librubberband_extralibs "-lstdc++"
-enabled libshine && require_pkg_config libshine shine shine/layer3.h shine_encode_buffer
+enabled libshine && require "shine" shine/layer3.h shine_encode_buffer -lshine -lm
enabled libsmbclient && { check_pkg_config libsmbclient smbclient libsmbclient.h smbc_init ||
require libsmbclient libsmbclient.h smbc_init -lsmbclient; }
enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++

View File

@@ -12,7 +12,7 @@ version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py
android.numeric_version = 20251122
requirements = kivy==2.3.0,libbz2,sqlite3,pillow==10.2.0,qrcode==7.3.1,usb4a,usbserial4a,able_recipe,libwebp,libogg,libopus,opusfile,numpy,cryptography,ffpyplayer,codec2,pycodec2,sh,pynacl,typing-extensions,mistune>=3.0.2,beautifulsoup4,lxst
requirements = kivy==2.3.0,libbz2,sqlite3,pillow==10.2.0,qrcode==7.3.1,usb4a,usbserial4a,able_recipe,libwebp,libogg,libopus,opusfile,numpy,cryptography,codec2,pycodec2,sh,pynacl,typing-extensions,mistune>=3.0.2,beautifulsoup4,lxst
android.gradle_dependencies = com.android.support:support-compat:28.0.0
#android.enable_androidx = True