Search code examples
androidwebrtcopenh264

Is it possible to install a H.264 software codec to Google's native Android WebRTC libraries?


According to this post (How to detect Android H.264 hardware acceleration capability) and also personal experience, the latest Android native libraries for WebRTC ('org.webrtc:google-webrtc:1.0.23546') do not support H.264 unless there is a hardware decoder present for it.

So far, this only effects me when using the emulator, but I understand that some devices it won't work, so that could to be a large problem.

Cisco has their H.264 software decoder available at https://github.com/cisco/openh264 and I'd like to know if there is a way to use that or something else to install software H.264 in a way that will work with WebRTC on devices that don't have hardware decoding.

Additionally, I can't seem to find a support matrix for H.264 hardware decoding on devices.


Solution

  • Can be done using JCodec. Google provides access to create a custom decoder in Java.

    -- Decoder.decodeFrame is already in YUV format

    -- Data for Y,U,V can be found at frame.getPlaneData(0/1/2)

    -- StrideY/U/V is frame.getWidth() >> frame.getColor().compWidth[planeIndex]

    -- According to the header in "org.jcodec.common.model.Picture" data is shifted by 128. Necessary to adjust by (byte) (a[i] + 128).