From 541fe992ea86b3902f0e0f776167555da6dbca01 Mon Sep 17 00:00:00 2001 From: Dexer <73297572+DexerBR@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:18:57 -0300 Subject: [PATCH 1/6] bump FFMpegRecipe and PyAVRecipe versions --- pythonforandroid/recipes/av/__init__.py | 6 ++++- .../patches/compilation_syntax_errors.patch | 27 +++++++++++++++++++ pythonforandroid/recipes/ffmpeg/__init__.py | 6 +---- 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 pythonforandroid/recipes/av/patches/compilation_syntax_errors.patch diff --git a/pythonforandroid/recipes/av/__init__.py b/pythonforandroid/recipes/av/__init__.py index 816f27e35f..d5c1acae54 100644 --- a/pythonforandroid/recipes/av/__init__.py +++ b/pythonforandroid/recipes/av/__init__.py @@ -5,11 +5,15 @@ class PyAVRecipe(CythonRecipe): name = "av" - version = "10.0.0" + version = "13.0.0" url = "https://github.com/PyAV-Org/PyAV/archive/v{version}.zip" depends = ["python3", "cython", "ffmpeg", "av_codecs"] opt_depends = ["openssl"] + patches = ['patches/compilation_syntax_errors.patch'] + + def prebuild_arch(self, arch): + self.apply_patches(arch) def get_recipe_env(self, arch, with_flags_in_cc=True): env = super().get_recipe_env(arch) diff --git a/pythonforandroid/recipes/av/patches/compilation_syntax_errors.patch b/pythonforandroid/recipes/av/patches/compilation_syntax_errors.patch new file mode 100644 index 0000000000..c9a7e9adb3 --- /dev/null +++ b/pythonforandroid/recipes/av/patches/compilation_syntax_errors.patch @@ -0,0 +1,27 @@ +diff --git a/av/container/streams.pyx b/av/container/streams.pyx +index 17e4992..502ac5a 100644 +--- a/av/container/streams.pyx ++++ b/av/container/streams.pyx +@@ -144,7 +144,7 @@ cdef class StreamContainer: + + return stream_index + +- def best(self, str type, /, Stream related = None): ++ def best(self, str type, Stream related=None): + """best(type: Literal["video", "audio", "subtitle", "attachment", "data"], /, related: Stream | None) + Finds the "best" stream in the file. Wraps :ffmpeg:`av_find_best_stream`. Example:: + +diff --git a/av/filter/context.pyx b/av/filter/context.pyx +index b820d3d..8908b56 100644 +--- a/av/filter/context.pyx ++++ b/av/filter/context.pyx +@@ -77,7 +77,8 @@ cdef class FilterContext: + + @property + def graph(self): +- if (graph := self._graph()): ++ graph = self._graph() ++ if graph: + return graph + else: + raise RuntimeError("graph is unallocated") diff --git a/pythonforandroid/recipes/ffmpeg/__init__.py b/pythonforandroid/recipes/ffmpeg/__init__.py index 9414552f0b..c6068bd999 100644 --- a/pythonforandroid/recipes/ffmpeg/__init__.py +++ b/pythonforandroid/recipes/ffmpeg/__init__.py @@ -4,20 +4,16 @@ class FFMpegRecipe(Recipe): - version = 'n4.3.1' + version = 'n6.1.2' # 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 From c8f7a5cd39d7798d0514762b3f90f1b42b48337a Mon Sep 17 00:00:00 2001 From: Dexer <73297572+DexerBR@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:25:55 -0300 Subject: [PATCH 2/6] remove patch no longer needed --- .../recipes/ffmpeg/patches/configure.patch | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 pythonforandroid/recipes/ffmpeg/patches/configure.patch diff --git a/pythonforandroid/recipes/ffmpeg/patches/configure.patch b/pythonforandroid/recipes/ffmpeg/patches/configure.patch deleted file mode 100644 index cacf0294e2..0000000000 --- a/pythonforandroid/recipes/ffmpeg/patches/configure.patch +++ /dev/null @@ -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++ \ No newline at end of file From 63fc70324d3afddc58b1d842497b9e8dca3539de Mon Sep 17 00:00:00 2001 From: Dexer <73297572+DexerBR@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:29:00 -0300 Subject: [PATCH 3/6] re-add patch; fix linking with static libx264 --- pythonforandroid/recipes/ffmpeg/__init__.py | 9 +++++--- .../recipes/ffmpeg/patches/configure.patch | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 pythonforandroid/recipes/ffmpeg/patches/configure.patch diff --git a/pythonforandroid/recipes/ffmpeg/__init__.py b/pythonforandroid/recipes/ffmpeg/__init__.py index c6068bd999..90d64bfb5e 100644 --- a/pythonforandroid/recipes/ffmpeg/__init__.py +++ b/pythonforandroid/recipes/ffmpeg/__init__.py @@ -8,7 +8,8 @@ class FFMpegRecipe(Recipe): # 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'] + opts_depends = ['openssl', 'ffpyplayer_codecs', 'av_codecs'] + patches = ['patches/configure.patch'] def should_build(self, arch): build_dir = self.get_build_dir(arch.arch) @@ -39,7 +40,9 @@ def build_arch(self, arch): '-DOPENSSL_API_COMPAT=0x10002000L'] ldflags += ['-L' + build_dir] - if 'ffpyplayer_codecs' in self.ctx.recipe_build_order: + codecs_opts = {"ffpyplayer_codecs", "av_codecs"} + if codecs_opts.intersection(self.ctx.recipe_build_order): + # Enable GPL flags += ['--enable-gpl'] @@ -48,7 +51,7 @@ def build_arch(self, arch): build_dir = Recipe.get_recipe( 'libx264', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] - ldflags += ['-lx264', '-L' + build_dir + '/lib/'] + ldflags += [build_dir + '/lib/' + 'libx264.a'] # libshine flags += ['--enable-libshine'] diff --git a/pythonforandroid/recipes/ffmpeg/patches/configure.patch b/pythonforandroid/recipes/ffmpeg/patches/configure.patch new file mode 100644 index 0000000000..e274359cb7 --- /dev/null +++ b/pythonforandroid/recipes/ffmpeg/patches/configure.patch @@ -0,0 +1,22 @@ +diff --git a/configure b/configure +index 5af693c954..d1d0a4f0a2 100755 +--- a/configure ++++ b/configure +@@ -6800,7 +6800,7 @@ enabled librsvg && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/ + 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 libshaderc && require_pkg_config spirv_compiler "shaderc >= 2019.1" shaderc/shaderc.h shaderc_compiler_initialize +-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++ +@@ -6850,7 +6850,7 @@ enabled libvpx && { + enabled libwebp && { + enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion + enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; } +-enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode && ++enabled libx264 && require "x264" "stdint.h x264.h" x264_encoder_encode && + require_cpp_condition libx264 x264.h "X264_BUILD >= 122" && { + [ "$toolchain" != "msvc" ] || + require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } && From 41077f3c3c3faca739bfcc7db777f9a537a84801 Mon Sep 17 00:00:00 2001 From: Dexer <73297572+DexerBR@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:30:30 -0300 Subject: [PATCH 4/6] remove unneeded override --- pythonforandroid/recipes/av/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pythonforandroid/recipes/av/__init__.py b/pythonforandroid/recipes/av/__init__.py index d5c1acae54..70205e37a0 100644 --- a/pythonforandroid/recipes/av/__init__.py +++ b/pythonforandroid/recipes/av/__init__.py @@ -12,9 +12,6 @@ class PyAVRecipe(CythonRecipe): opt_depends = ["openssl"] patches = ['patches/compilation_syntax_errors.patch'] - def prebuild_arch(self, arch): - self.apply_patches(arch) - def get_recipe_env(self, arch, with_flags_in_cc=True): env = super().get_recipe_env(arch) From 18b4e4650e6f1305e02e8c71e06f2c5f6d39c504 Mon Sep 17 00:00:00 2001 From: Dexer <73297572+DexerBR@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:18:16 -0300 Subject: [PATCH 5/6] add comment --- pythonforandroid/recipes/ffmpeg/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pythonforandroid/recipes/ffmpeg/__init__.py b/pythonforandroid/recipes/ffmpeg/__init__.py index 90d64bfb5e..3bc824834f 100644 --- a/pythonforandroid/recipes/ffmpeg/__init__.py +++ b/pythonforandroid/recipes/ffmpeg/__init__.py @@ -51,6 +51,8 @@ def build_arch(self, arch): build_dir = Recipe.get_recipe( 'libx264', self.ctx).get_build_dir(arch.arch) cflags += ['-I' + build_dir + '/include/'] + # Newer versions of FFmpeg prioritize the dynamic library and ignore + # the static one, unless the static library path is explicitly set. ldflags += [build_dir + '/lib/' + 'libx264.a'] # libshine From c4b3314768f2604af3aeed6ee1ac75a3e1f34372 Mon Sep 17 00:00:00 2001 From: Dexer <73297572+DexerBR@users.noreply.github.com> Date: Tue, 8 Oct 2024 09:24:05 -0300 Subject: [PATCH 6/6] bump pyav to 13.1.0 --- pythonforandroid/recipes/av/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/av/__init__.py b/pythonforandroid/recipes/av/__init__.py index 70205e37a0..f189467add 100644 --- a/pythonforandroid/recipes/av/__init__.py +++ b/pythonforandroid/recipes/av/__init__.py @@ -5,7 +5,7 @@ class PyAVRecipe(CythonRecipe): name = "av" - version = "13.0.0" + version = "13.1.0" url = "https://github.com/PyAV-Org/PyAV/archive/v{version}.zip" depends = ["python3", "cython", "ffmpeg", "av_codecs"]