kivy / kivy/python-for-android
bug: recipes: ffmpeg: hardware acc flags override --disable-everything flag
- 主要语言
- Python
- 星标
- 8.9k
- 派生
- 2k
- 平均合并
- 12 小时 20 分钟
- 30 天内合并 PR
- 9
描述
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.
贡献指南
调研方向
从 pythonforandroid/recipes/ffmpeg/__init__.py 开始,重点查看第 39-47 行附近的 flag 设置,以及第 94 行附近的 ffpyplayer_codecs/av_codecs 分支。阅读 build_arch 和 should_build(),了解干净的 recipe 构建如何生成随产品发布的二进制文件,然后验证相关的 CLI、HLS 和 RTSP 行为。当禁用 flag 和硬件加速保持兼容,同时不丢失所需的 codec 或协议时,即可完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, python
- 领域
- build-system, mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100