kivy / kivy/python-for-android

bug: recipes: ffmpeg: hardware acc flags override --disable-everything flag

Open
#3,382 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8.9k
Forks
2k
Avg merge
12h 20m
Merged PRs (30d)
9

Description

The ffmpeg recipe declares `flags = ['--disable-everything']` but then right below it
overrides the flags again (instead of appending):

https://github.com/kivy/python-for-android/blob/e772ad93f20a61c0bbe1cf8955e073cfb41062e1/pythonforandroid/recipes/ffmpeg/__init__.py#L39-L47

The obvious fix is simple, but i have no means of testing the actual recipe, so I won't open a PR. Someone who is actually using this ffmpeg recipe should be testing the fix.

My LLM also recommends a patch like this to keep the hardware acceleration functional after this change:

Click to show patch:

```patch
diff --git a/pythonforandroid/recipes/ffmpeg/__init__.py b/pythonforandroid/recipes/ffmpeg/__init__.py
index 24004868..33724ee2 100644
--- a/pythonforandroid/recipes/ffmpeg/__init__.py
+++ b/pythonforandroid/recipes/ffmpeg/__init__.py
@@ -98,10 +98,18 @@ class FFMpegRecipe(Recipe):
else:
# Enable codecs only for .mp4:
flags += [
- '--enable-parser=aac,ac3,h261,h264,mpegaudio,mpeg4video,mpegvideo,vc1',
- '--enable-decoder=aac,h264,mpeg4,mpegvideo',
+ '--enable-parser=aac,ac3,h261,h264,hevc,mpegaudio,mpeg4video,mpegvideo,vc1',
+ '--enable-decoder=aac,h264,hevc,mpeg4,mpegvideo',
+ # --enable-mediacodec only builds the MediaCodec support layer;
+ # the hardware decoders are separate components that
+ # --disable-everything switches off, so enable them explicitly.
+ # They are never picked automatically -- avcodec_find_decoder()
+ # returns the first match in list order and every software
+ # decoder is declared first -- so callers ask for them by name
+ # and the software decoders above stay as the fallback.
+ '--enable-decoder=h264_mediacodec,hevc_mediacodec,mpeg4_mediacodec,mpeg2_mediacodec',
'--enable-muxer=h264,mov,mp4,mpeg2video',
- '--enable-demuxer=aac,h264,m4v,mov,mpegvideo,vc1,rtsp',
+ '--enable-demuxer=aac,h264,hevc,m4v,mov,mpegvideo,vc1,rtsp',
]

# needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52

```

It also mentions the following issues after reviewing this change:

1. The shipped ffmpeg CLI loses all encoders. --enable-encoders appears only at line 94, inside the ffpyplayer_codecs/av_codecs branch. The minimal branch enables muxers and zero encoders. build_arch ends with cp ffmpeg ./lib/libffmpegbin.so (added 2026-01-19, #3276 — after the #3092 bug), so that binary has only ever existed in "everything enabled" form. Post-fix it can remux but any -c:v/-c:a fails with "Unknown encoder".
2. HLS breaks. --enable-protocol=...,hls builds hlsproto.c (deprecated, handles hls+http://). Real playback needs the hls demuxer — ff_hls_demuxer is a distinct component, it's not in the demuxer list, and hls_demuxer_select additionally requires mpegts_demuxer aac_demuxer ac3_demuxer eac3_demuxer, none enabled.
3. RTSP breaks. rtsp_demuxer_select="http_protocol rtpdec" (configure:3682) — it does not pull rtp_protocol, and the protocol list is file,http,hls,udp,tcp with no rtp. Result: Protocol not found.

Also real but lower-stakes: mp4 audio is aac-only (mp3/ac3/alac tracks decode to nothing), and should_build() returns early on an existing libavcodec.so, so nobody sees any of this without a clean build.

According to the git blame this was introduced in https://github.com/kivy/python-for-android/pull/3092 by @DexerBR, maybe @DexerBR has some way of testing a fix.

Contributor guide

Open the contributing guide

Research direction

Start in pythonforandroid/recipes/ffmpeg/__init__.py, especially the flag setup around lines 39-47 and the ffpyplayer_codecs/av_codecs branch near line 94. Read build_arch and should_build() to understand how a clean recipe build produces the shipped binary, then verify the relevant CLI, HLS, and RTSP behavior. Done means the disable flags and hardware acceleration remain compatible without losing the required codecs or protocols.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, python
Domain
build-system, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.