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)