Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaCodec Encoded video has green bar at bottom and chrominance screwed up

I started a project from Grafika and modified it. I've got a framework (not too different from the original) which captures a preview from the Camera and continuously encodes it to a video at the same time both at different resolutions.

MediaCodec (for encoding) is configured to use COLOR_FormatSurface in order for us to be able to render to the Surface queried using getInputSurface() using GLES.

The media format is set to MIME Type video/avc

For most phones, this setup works perfectly.

But for a few phones, the encoded video has the chrominance values slightly skewed and a green bar at the bottom.

Currently the encoder surface is of 640x360 resolution. EGLConfig choosen to render to the surface supports 32 bit RGBA format.

The preview is perfect in all phones.

So I am assuming there's some thing wrong with the encoder parameters either on the application side or the OS framework side.

It's happening on Android 4.4. - Not sure, if it's reproducible on 5.*.

![Green bar image]2

like image 703
Sahil Bajaj Avatar asked Sep 18 '15 08:09

Sahil Bajaj


1 Answers

I'll answer that for myself just in case anyone else find it useful.

Apparently the issue only occurs on a few select chipsets such as MediaTek ones, which don't support non multiple of 16 resolutions. In my case it was 640x360 (where height is a multiple of 8). To partially solve it, I added a check in the App code, if the encoder is Omx.mtk, then reconfigure the encoder with width/height as the next multiple of 16, which comes out to be 640x368 in my case (closest to the requirement i.e. 360p).

For me, YouTube player adds a slight blanking on either side, which is the best we can do with those encoders.

In case you don't have dependency on any third party APIs/players etc

like image 94
Sahil Bajaj Avatar answered Sep 23 '22 23:09

Sahil Bajaj