magiclen/FFmpeg-For-MagicLen-Applications

"No Java Virtual Machine has been registered" error

Closed this issue · 1 comments

Hello,
I compiled FFmpeg on my machine to enable "mediacodec" library.
This is the command line to configure the compilation:

./configure --cross-prefix=/root/arm64-toolchains-r14b/bin/aarch64-linux-android- --sysroot=/root/arm64-toolchains-r14b/sysroot/ --arch=arm64 --target-os=android --extra-cflags="-pie" --extra-ldflags="-pie" --bindir="$HOME/bin" --enable-gpl --disable-shared --enable-static --enable-runtime-cpudetect --enable-hwaccels --enable-neon --enable-jni --enable-mediacodec --enable-decoder=hevc_mediacodec --enable-omx --enable-nonfree --enable-pthreads

The FFmpeg command line works just fine.
However, when I run FFmpeg with "mediacodec" decoder decode a video sequence I got the error below.
Here is the command I used: "-vcodec hevc_mediacodec -i <video_sequence> -f null /dev/null"

​ffmpeg version 4.0.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.9.x (GCC) 20150123 (prerelease)
Builder magiclen.org
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, matroska,webm, from '/sdcard/hevc.mkv':
Metadata:
COMPATIBLE_BRANDS: iso4hvc1iso6
MAJOR_BRAND : iso4
MINOR_VERSION : 1
ENCODER : Lavf56.3.100
Duration: 00:00:30.10, start: 0.067000, bitrate: 2827 kb/s
Stream #0:0(und): Video: hevc (Main), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 29.97 tbc (default)
Metadata:
CREATION_TIME : 2016-02-04 02:54:49
LANGUAGE : und
HANDLER_NAME : hevc@GPAC0.5.2-DEV-rev565-g71748d7-ab-suite
[amediaformat @ 0x7fb620f100] No Java virtual machine has been registered
[hevc_mediacodec @ 0x7fb6248a00] Failed to create media format
Stream mapping:
Stream #0:0 -> #0:0 (hevc (hevc_mediacodec) -> wrapped_avframe (native))
Error while opening decoder for input stream #0:0 : Generic error in an external library

Please, is there something wrong in the configuration process or any other thing?
Any little help is welcome.
Thank you in advance

I think Android applications cannot use MediaCodec without through JNI. Because you have no chance to link your FFmpeg program with JVM and MediaCodec.

Obviously, you use the --enable-jni option. Because FFmpeg needs to be as a (shared) library included in your Java program, and you need to declare some native functions in your Java code according to JNI header files. Then, you call those functions by passing Java MediaCodec objects to FFmpeg so that it can help you do the computation.

To put it simply, it is

Java MediaCodec -> (JNI) -> FFmpeg, but not Java -> (Execute) -> FFmpeg -> MediaCodec