zoukankan      html  css  js  c++  java
  • MediaCodec.configure Picture Width(1080) or Height(2163) invalid, should N*2

    异常如下:

     Picture Width(1080) or Height(2163) invalid, should N*2

    报错的地方是MediaCodec.configure

    mMediaCodec.configure(mMediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);

    引起这个崩溃的原因正如错误描述的那样,意思是:视频的宽和高必须是2的证书倍,及width=N*2,height=N*2

    所以解决办法也非常简单,只需要重新设置视频的宽高,并做一下变形使其成为2的整数倍就OK了。

    可以进行如下设置:

     int formatWidth = width;
            int formatHeight = height;
            if ((formatWidth & 1) == 1) {
                formatWidth--;
            }
            if ((formatHeight & 1) == 1) {
                formatHeight--;
            }

    使用的时候直接使用formatWidth和formatHeight,然后你就会发现以上的异常就会被修复。

  • 相关阅读:
    获取目录下所有文件名
    毕业论文endnote使用
    CoinChange
    sublime3个人配置
    2015-12-31
    2015-12-09
    #define DEBUG用法
    fiddler介绍
    app测试模块
    android SDK_安装配置_使用
  • 原文地址:https://www.cnblogs.com/tony-yang-flutter/p/14734737.html
Copyright © 2011-2022 走看看