Skip to content

FFmpeg MediaCodec issues #2

@floens

Description

@floens

MediaCodec is the API on Android that implements hardware accelerated video encoding and decoding. FFmpeg implements it as one of their hw backends. The FFmpeg implementation calls the Java MediaCodec methods with the JNI.

A few notes:
The jni is constantly attached and detached to the native thread, causing a new Thread object and related objects to be created multiple times per frame. This causes enormous spikes in memory that causes the GC to kick in every few seconds.
This issue is easy to resolve: don't detach the jni thread at all.
Fixed with FFmpeg/FFmpeg@376d8fb

On a Nexus 9 (or just Nougat?) the H264 profiles are not detected properly, resulting in slow playback / incorrect color profiles.

MediaCodec has a native api since Lollipop. Since this app is only supported on Lollipop or higher, we might change the FFmpeg implementation to use the native version. The author of the ffmpeg mediacodec wrapper has kept this in mind, see the note at the top of mediacodec_wrapper.h. The api is aligned with the one of Android.

Should be doable, but it isn't high priority because it isn't going to magically fix the issues above: the code uses buffers that aren't copied between the jni and native code so the jni performance impact is minimal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions