Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg: enable jni and mediacodec #16680

Merged
merged 2 commits into from
Jun 13, 2023
Merged

ffmpeg: enable jni and mediacodec #16680

merged 2 commits into from
Jun 13, 2023

Conversation

truboxl
Copy link
Contributor

@truboxl truboxl commented May 15, 2023

Close #16633

@truboxl truboxl marked this pull request as draft May 15, 2023 22:44
@truboxl
Copy link
Contributor Author

truboxl commented May 17, 2023

Using mediacodec can crash my Android 11 device into a hard reboot. Not sure it's because of my input video or what using the commands provided in the other issue.

It does work for short videos. But expect sacrifice encoding in high quality for shorter time.

Next step to check it doesn't break Android 7 and Termux Docker...

@truboxl
Copy link
Contributor Author

truboxl commented May 20, 2023

Looks like when ffmpeg is built with mediacodec will break on Termux Docker:

~ $ ffmpeg -h
CANNOT LINK EXECUTABLE "ffmpeg": library "libandroid.so" not found
linker: CANNOT LINK EXECUTABLE "ffmpeg": library "libandroid.so" not found

with mediacodec

~ $ readelf -d $PREFIX/lib/libavcodec.so.60
Dynamic section at offset 0xede670 contains 50 entries:
  Tag                Type           Name/Value
  0x000000000000001d (RUNPATH)      Library runpath: [/data/data/com.termux/files/usr/lib]
  0x0000000000000001 (NEEDED)       Shared library: [libswresample.so.4]
  0x0000000000000001 (NEEDED)       Shared library: [libavutil.so.58]
  0x0000000000000001 (NEEDED)       Shared library: [libandroid.so]
  0x0000000000000001 (NEEDED)       Shared library: [libvpx.so.8]
  0x0000000000000001 (NEEDED)       Shared library: [libm.so]
  0x0000000000000001 (NEEDED)       Shared library: [libwebpmux.so]
  0x0000000000000001 (NEEDED)       Shared library: [libwebp.so]
  0x0000000000000001 (NEEDED)       Shared library: [libiconv.so]
  0x0000000000000001 (NEEDED)       Shared library: [liblcms2.so]
  0x0000000000000001 (NEEDED)       Shared library: [liblzma.so.5]
  0x0000000000000001 (NEEDED)       Shared library: [libdav1d.so]
  0x0000000000000001 (NEEDED)       Shared library: [libaom.so]
  0x0000000000000001 (NEEDED)       Shared library: [libmp3lame.so]
  0x0000000000000001 (NEEDED)       Shared library: [libopus.so]
  0x0000000000000001 (NEEDED)       Shared library: [librav1e.so]
  0x0000000000000001 (NEEDED)       Shared library: [libtheoraenc.so.1]
  0x0000000000000001 (NEEDED)       Shared library: [libtheoradec.so.1]
  0x0000000000000001 (NEEDED)       Shared library: [libvorbis.so]
  0x0000000000000001 (NEEDED)       Shared library: [libvorbisenc.so]
  0x0000000000000001 (NEEDED)       Shared library: [libx264.so.164]
  0x0000000000000001 (NEEDED)       Shared library: [libx265.so]
  0x0000000000000001 (NEEDED)       Shared library: [libxvidcore.so.4]
  0x0000000000000001 (NEEDED)       Shared library: [libz.so.1]
  0x0000000000000001 (NEEDED)       Shared library: [libdl.so]
  0x0000000000000001 (NEEDED)       Shared library: [libc.so]
  0x000000000000000e (SONAME)       Library soname: [libavcodec.so.60]
  0x000000000000001e (FLAGS)        SYMBOLIC BIND_NOW
  0x000000006ffffffb (FLAGS_1)      NOW
  0x0000000000000007 (RELA)         0x8848
  0x0000000000000008 (RELASZ)       398184 (bytes)
  0x0000000000000009 (RELAENT)      24 (bytes)
  0x000000006ffffff9 (RELACOUNT)    16433
  0x0000000000000017 (JMPREL)       0x69bb0
  0x0000000000000002 (PLTRELSZ)     13296 (bytes)
  0x0000000000000003 (PLTGOT)       0xee0ce8
  0x0000000000000014 (PLTREL)       RELA
  0x0000000000000006 (SYMTAB)       0x308
  0x000000000000000b (SYMENT)       24 (bytes)
  0x0000000000000005 (STRTAB)       0x51f0
  0x000000000000000a (STRSZ)        13908 (bytes)
  0x000000006ffffef5 (GNU_HASH)     0x4dc8
  0x000000000000001a (FINI_ARRAY)   0xee0660
  0x000000000000001c (FINI_ARRAYSZ) 16 (bytes)
  0x000000006ffffff0 (VERSYM)       0x46e8
  0x000000006ffffffc (VERDEF)       0x4c90
  0x000000006ffffffd (VERDEFNUM)    2
  0x000000006ffffffe (VERNEED)      0x4cc8
  0x000000006fffffff (VERNEEDNUM)   8
  0x0000000000000000 (NULL)         0x0

no mediacodec

~ $ readelf -d $PREFIX/lib/libavcodec.so.60
Dynamic section at offset 0xecad00 contains 48 entries:
  Tag                Type           Name/Value
  0x000000000000001d (RUNPATH)      Library runpath: [/data/data/com.termux/files/usr/lib]
  0x0000000000000001 (NEEDED)       Shared library: [libswresample.so.4]
  0x0000000000000001 (NEEDED)       Shared library: [libavutil.so.58]
  0x0000000000000001 (NEEDED)       Shared library: [libvpx.so.8]
  0x0000000000000001 (NEEDED)       Shared library: [libm.so]
  0x0000000000000001 (NEEDED)       Shared library: [libwebpmux.so]
  0x0000000000000001 (NEEDED)       Shared library: [libwebp.so]
  0x0000000000000001 (NEEDED)       Shared library: [libiconv.so]
  0x0000000000000001 (NEEDED)       Shared library: [liblcms2.so]
  0x0000000000000001 (NEEDED)       Shared library: [liblzma.so.5]
  0x0000000000000001 (NEEDED)       Shared library: [libdav1d.so]
  0x0000000000000001 (NEEDED)       Shared library: [libaom.so]
  0x0000000000000001 (NEEDED)       Shared library: [libmp3lame.so]
  0x0000000000000001 (NEEDED)       Shared library: [libopus.so]
  0x0000000000000001 (NEEDED)       Shared library: [librav1e.so]
  0x0000000000000001 (NEEDED)       Shared library: [libtheoraenc.so.1]
  0x0000000000000001 (NEEDED)       Shared library: [libtheoradec.so.1]
  0x0000000000000001 (NEEDED)       Shared library: [libvorbis.so]
  0x0000000000000001 (NEEDED)       Shared library: [libvorbisenc.so]
  0x0000000000000001 (NEEDED)       Shared library: [libx264.so.164]
  0x0000000000000001 (NEEDED)       Shared library: [libx265.so]
  0x0000000000000001 (NEEDED)       Shared library: [libxvidcore.so.4]
  0x0000000000000001 (NEEDED)       Shared library: [libz.so.1]
  0x0000000000000001 (NEEDED)       Shared library: [libc.so]
  0x000000000000000e (SONAME)       Library soname: [libavcodec.so.60]
  0x000000000000001e (FLAGS)        SYMBOLIC BIND_NOW
  0x000000006ffffffb (FLAGS_1)      NOW
  0x0000000000000007 (RELA)         0x8668
  0x0000000000000008 (RELASZ)       384096 (bytes)
  0x0000000000000009 (RELAENT)      24 (bytes)
  0x000000006ffffff9 (RELACOUNT)    15859
  0x0000000000000017 (JMPREL)       0x662c8
  0x0000000000000002 (PLTRELSZ)     13056 (bytes)
  0x0000000000000003 (PLTGOT)       0xecd358
  0x0000000000000014 (PLTREL)       RELA
  0x0000000000000006 (SYMTAB)       0x308
  0x000000000000000b (SYMENT)       24 (bytes)
  0x0000000000000005 (STRTAB)       0x50d0
  0x000000000000000a (STRSZ)        13713 (bytes)
  0x000000006ffffef5 (GNU_HASH)     0x4ca8
  0x000000000000001a (FINI_ARRAY)   0xecccf0
  0x000000000000001c (FINI_ARRAYSZ) 16 (bytes)
  0x000000006ffffff0 (VERSYM)       0x45f8
  0x000000006ffffffc (VERDEF)       0x4b8c
  0x000000006ffffffd (VERDEFNUM)    2
  0x000000006ffffffe (VERNEED)      0x4bc4
  0x000000006fffffff (VERNEEDNUM)   7
  0x0000000000000000 (NULL)         0x0

@truboxl
Copy link
Contributor Author

truboxl commented May 20, 2023

Seems to work fine (can use other libs, using mediacodec will be errored during runtime) by adding a stub libandroid.so to $PREFIX/lib for Termux Docker.

So we dont have to build 2 variants of ffmpeg. But we haven't package libandroid.so yet...

@truboxl truboxl force-pushed the ffmpeg-mediacodec branch from 5652f0d to f52d1de Compare June 3, 2023 16:41
truboxl added 2 commits June 4, 2023 00:45
Enable JNI is a prerequisite to enable mediacodec support
@truboxl truboxl force-pushed the ffmpeg-mediacodec branch from f52d1de to 90a558e Compare June 3, 2023 16:45
@truboxl truboxl marked this pull request as ready for review June 4, 2023 07:13
@truboxl
Copy link
Contributor Author

truboxl commented Jun 11, 2023

Will merge this by tomorrow 12am UTC+8 if no more reviews

@truboxl truboxl merged commit 097206d into master Jun 13, 2023
@truboxl truboxl deleted the ffmpeg-mediacodec branch June 13, 2023 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ffmpeg is missing --enable-jni --enable-mediacodec
1 participant