报错代码:
final MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, mWidth, mHeight);
mMediaCodec.configure(format, null, null,MediaCodec.CONFIGURE_FLAG_ENCODE);
原因:传入放入宽高中高不是2的倍数,换言之,是个单数。
解决:
int formatWidth = mWidth;
int formatHeight = mHeight;
if ((formatWidth & 1) == 1) {
formatWidth--;
}
if ((formatHeight & 1) == 1) {
formatHeight--;
}
final MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, formatWidth, formatHeight);
本文介绍了一种常见的MediaCodec配置错误,即视频宽度和高度不是2的倍数时导致的问题,并提供了解决方案,通过调整视频尺寸确保其为偶数。
2791

被折叠的 条评论
为什么被折叠?



