MediaCodec编码视频在底部有绿色条纹,色度变差 [英] MediaCodec Encoded video has green bar at bottom and chrominance screwed up

查看:1609
本文介绍了MediaCodec编码视频在底部有绿色条纹,色度变差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从

解决方案

我会为自己回答,以防其他人觉得有用。



显然,问题只发生在几个选择的芯片组,如联发科之类的,不支持16 分辨率的非复数。在我的情况下是640x360(高度是8的倍数)。为了部分解决它,我添加了一个检查应用程序代码,如果编码器是 Omx.mtk ,然后重新配置宽度/高度的编码器作为下一个复数16 ,在我的情况下,最接近640x368(最接近要求,即360p)。



对于我来说,YouTube播放器增加了一个轻微的消隐任何一方,这是我们可以用这些编码器最好的。



如果您没有依赖任何第三方API /播放器等。 b $ b

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.*.

]2

解决方案

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

这篇关于MediaCodec编码视频在底部有绿色条纹,色度变差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆