版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhang___yong/article/details/82760756
报错代码:
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);