android.media.MediaCodec$CodecException: Error 0xfffffc0e

報錯代碼:

        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);
       

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章