MediaCodec 编码的视频底部有绿色条,色度搞砸了 [英] MediaCodec Encoded video has green bar at bottom and chrominance screwed up

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

问题描述

我从

解决方案

我会自己回答,以防万一其他人觉得它有用.

显然,该问题仅出现在少数精选芯片组上,例如 MediaTek 芯片组,它们不支持非 16 的倍数 分辨率.就我而言,它是 640x360(高度是 8 的倍数).为了部分解决它,我在 App 代码中添加了一个检查,如果编码器是 Omx.mtk,则将编码器的宽度/高度重新配置为 16 的下一个倍数,在我的情况下是 640x368(最接近要求,即 360p).

对我来说,YouTube 播放器在两侧添加了一个轻微的空白,这是我们可以使用这些编码器做的最好的事情.

如果您不依赖任何第三方 API/播放器等

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天全站免登陆