[英]Android - Video encoding quality with MediaCodec
我在Surface上绘制openGL图像(并旋转它们)。 对于某些图像,当我使用MediaCodec编码视频时,结果看起来像是像素化的或压缩的。
原始背景图片:
结果编码:
您可以在左下角看到它是像素化的。
这是我用来创建MediaCodec编码器的值:
int width = 800;
int height = 800;
int bitRate = 10485760; // bps, = 10Mbps (1080p)
bufferInfo = new MediaCodec.BufferInfo();
MediaFormat format = MediaFormat.createVideoFormat(GLVideoEncoderImpl.MIME_TYPE, width, height);
// Set some properties. Failing to specify some of these can cause the MediaCodec
// configure() call to throw an unhelpful exception.
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
format.setInteger(MediaFormat.KEY_FRAME_RATE, 30);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);
try {
mediaCodec = MediaCodec.createEncoderByType(GLVideoEncoderImpl.MIME_TYPE);
} catch (IOException e) {
e.printStackTrace();
UtilsAndroid.throwException("Impossible to create media codec");
}
mediaCodec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
是否可以提高输出质量? 提前致谢
对于某些图像,结果看起来像素化或压缩。
好吧,这就是有损视频压缩的作用,尤其是当您查看视频帧的静止图像时(视频压缩是令人讨厌的,并且感知错误取决于动画的事实,因此您看不到它)。
尝试的事情:
但是,请注意,大多数视频编码器旨在压缩现实世界中的视频,并且在设计感知错误时会考虑到这一点。 除非您以非常高的比特率运行它们,否则大多数压缩简单的渐变填充,线条图等时都会产生垃圾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.