From 602bda43d9895dc531004848546a142b55c53d86 Mon Sep 17 00:00:00 2001 From: Zhaoqi Xu Date: Tue, 29 Sep 2026 12:03:21 +0800 Subject: [PATCH] fix(recipes): drop dead ffmpeg --disable-everything flag The ffmpeg recipe set flags = ['--disable-everything'] and then immediately reassigned flags to the JNI/MediaCodec list, so the disable-everything line was dead code (issue #3382). Remove it instead of re-enabling it: existing apps rely on FFmpeg's default components, including the MediaCodec decoders and the HLS demuxer. Keep the hardware acceleration flags in get_base_configure_flags(), update the comments, and cover the behaviour with a unit test. Fixes #3382 --- pythonforandroid/recipes/ffmpeg/__init__.py | 25 ++++++++++++++------- tests/recipes/test_ffmpeg.py | 18 +++++++++++++++ 2 files changed, 35 insertions(+), 8 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..2a58add7c1 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 are always passed before optional codecs. + + Enable Android hardware acceleration (JNI + MediaCodec) on top of + FFmpeg's default component set. ``--disable-everything`` is + intentionally not used: existing apps rely on default components + such as the MediaCodec decoders and the HLS demuxer (issue #3382). + """ + return [ + '--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', @@ -96,7 +104,8 @@ def build_arch(self, arch): '--enable-demuxers', ] else: - # Enable codecs only for .mp4: + # Make sure the .mp4 codecs are enabled (in addition to + # FFmpeg's default components): flags += [ '--enable-parser=aac,ac3,h261,h264,mpegaudio,mpeg4video,mpegvideo,vc1', '--enable-decoder=aac,h264,mpeg4,mpegvideo', diff --git a/tests/recipes/test_ffmpeg.py b/tests/recipes/test_ffmpeg.py new file mode 100644 index 0000000000..e709350080 --- /dev/null +++ b/tests/recipes/test_ffmpeg.py @@ -0,0 +1,18 @@ +import unittest + +from pythonforandroid.recipes.ffmpeg import FFMpegRecipe + + +class TestFFMpegRecipe(unittest.TestCase): + """TestCase for recipe :mod:`~pythonforandroid.recipes.ffmpeg`.""" + + def test_base_configure_flags(self): + """ + Hardware acceleration flags are enabled and ``--disable-everything`` + is not passed, so FFmpeg's default components (e.g. MediaCodec + decoders, HLS demuxer) stay available (issue #3382). + """ + flags = FFMpegRecipe.get_base_configure_flags() + self.assertNotIn("--disable-everything", flags) + self.assertIn("--enable-jni", flags) + self.assertIn("--enable-mediacodec", flags)