When I used the huawei phone for video compression, the following code went awry and captured the illegalStateException
encoder = MediaCodec.createEncoderByType(MIME_TYPE);
encoder.configure(outputFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
if (Build.VERSION.SDK_INT >= 18) {
inputSurface = new InputSurface(encoder.createInputSurface());
inputSurface.makeCurrent();
}
encoder.start();// Errors occur in this line
logcat
android.media.MediaCodec$CodecException: start failed
11-14 16:49:00.830 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.native_start(Native Method)
11-14 16:49:00.830 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.start(MediaCodec.java:2016)
11-14 16:49:07.287 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.native_stop(Native Method)
11-14 16:49:07.287 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.stop(MediaCodec.java:2032)
I'm having trobles with Mate9 and MediaCodec. I think that is something related to KEY_BIT_RATE or VIDEO SIZE values. Change these values and try again. Maybe you need a special treatment for greater video size.
When I used the huawei phone for video compression, the following code went awry and captured the illegalStateException
encoder = MediaCodec.createEncoderByType(MIME_TYPE); encoder.configure(outputFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); if (Build.VERSION.SDK_INT >= 18) { inputSurface = new InputSurface(encoder.createInputSurface()); inputSurface.makeCurrent(); } encoder.start();// Errors occur in this line
logcat
android.media.MediaCodec$CodecException: start failed 11-14 16:49:00.830 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.native_start(Native Method) 11-14 16:49:00.830 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.start(MediaCodec.java:2016) 11-14 16:49:07.287 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.native_stop(Native Method) 11-14 16:49:07.287 3001-3226/net.ezbim.ebim.enterprise W/System.err: at android.media.MediaCodec.stop(MediaCodec.java:2032)