【发布时间】:2016-06-02 06:22:30
【问题描述】:
我使用 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);
是否可以提高输出质量?提前致谢
【问题讨论】:
标签: android opengl-es video-encoding