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
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.
The ffmpeg recipe declares
flags = ['--disable-everything']but then right below itoverrides the flags again (instead of appending):
python-for-android/pythonforandroid/recipes/ffmpeg/__init__.py
Lines 39 to 47 in e772ad9
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:
It also mentions the following issues after reviewing this change:
ffmpeg,python3: include executable #3276 — after the Add hardware acceleration codecs to ffmpeg recipe #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".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 #3092 by @DexerBR, maybe @DexerBR has some way of testing a fix.