From b913e3800ba89a6e5b448271a2bbb5eadacf8688 Mon Sep 17 00:00:00 2001 From: Zhaoqi Xu Date: Tue, 29 Sep 2026 12:03:21 +0800 Subject: [PATCH] fix(recipes): keep ffmpeg --disable-everything with HW accel flags The mediacodec/jni enable list used assignment and dropped the --disable-everything baseline, so configure no longer started from an empty codec set (issue #3382). --- pythonforandroid/recipes/ffmpeg/__init__.py | 22 ++++++++++++++------- tests/recipes/test_ffmpeg.py | 17 ++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 tests/recipes/test_ffmpeg.py diff --git a/pythonforandroid/recipes/ffmpeg/__init__.py b/pythonforandroid/recipes/ffmpeg/__init__.py index 38c4ff4660..26d9032a83 100644 --- a/pythonforandroid/recipes/ffmpeg/__init__.py +++ b/pythonforandroid/recipes/ffmpeg/__init__.py @@ -32,20 +32,28 @@ def get_recipe_env(self, arch): env['NDK'] = self.ctx.ndk_dir return env + @staticmethod + def get_base_configure_flags(): + """Flags that must always be present before optional codecs. + + Start from ``--disable-everything`` then enable Android hardware + codecs. Using assignment for the hardware flags used to drop the + disable-everything baseline (issue #3382). + """ + return [ + '--disable-everything', + '--enable-jni', + '--enable-mediacodec', + ] + def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): env = arch.get_env() - flags = ['--disable-everything'] + flags = self.get_base_configure_flags() cflags = [] ldflags = [] - # enable hardware acceleration codecs - flags = [ - '--enable-jni', - '--enable-mediacodec' - ] - if 'openssl' in self.ctx.recipe_build_order: flags += [ '--enable-version3', diff --git a/tests/recipes/test_ffmpeg.py b/tests/recipes/test_ffmpeg.py new file mode 100644 index 0000000000..e3bb3a922d --- /dev/null +++ b/tests/recipes/test_ffmpeg.py @@ -0,0 +1,17 @@ +import unittest + +from pythonforandroid.recipes.ffmpeg import FFMpegRecipe + + +class TestFFMpegRecipe(unittest.TestCase): + """TestCase for recipe :mod:`~pythonforandroid.recipes.ffmpeg`.""" + + def test_base_configure_flags_keep_disable_everything(self): + """ + Hardware acceleration flags must append to ``--disable-everything``, + not replace it (issue #3382). + """ + flags = FFMpegRecipe.get_base_configure_flags() + self.assertEqual(flags[0], "--disable-everything") + self.assertIn("--enable-jni", flags) + self.assertIn("--enable-mediacodec", flags)