Search code examples
androidvideo-encodinghardware-accelerationandroid-hardwareandroid-mediacodec

Getting QualComm encoders to work via MediaCodec API


I am trying to do hardware encoding (avc) of NV12 stream using Android MediaCodec API.

When using OMX.qcom.video.encoder.avc, resolutions 1280x720 and 640x480 work fine, while the others (i.e. 640x360, 320x240, 800x480) produce output where chroma component seems shifted (please see snapshot).

I have double-checked that the input image is correct by saving it to a jpeg file. This problem only occurs on QualComm devices (i.e. Samsung Galaxy S4).

Anyone has this working properly? Any additional setup / quirks necessary?


Solution

  • Decoder(MediaCodec) has its MediaFormat, it can be received using getOutputFormat. Returned instance can be printed to log. And there you can see some useful information. For example in your case value like "slice-height" could be useful. I suspect that it is equal to height for 1280x720 and 640x480 and differs for other resolutions. Probably you should use this value to get chroma offset.