I'm trying to use MediaCodec to generate a mp4 file from a set of bitmaps i have.
After a lot of coding and testing I noticed that no example existent on internet or whatever work on the Android Studio emulator, but they do work in both of my real phone (android 7 and 9)... So i kept develoing only testing on real phones.
after a lot of coding and testing i got a working coding (working for both of my phones but crashing for the android emulator) and deployed to production.
My has been online for a couple of months and I have around 150 daily users, but around 30% of them are getting the same crash i noticed on the android emulator. so that isn't a limitation of the emulator.
E/ACodec: [OMX.google.h264.encoder] configureCodec returning error -38 signalError(omxError 0x80001001, internalError -2147483648) E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 3 E/MediaCodec: configure failed with err 0x80001001, resetting...
private static MediaCodecInfo selectCodec(String mimeType) {
int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) {
continue;
}
String[] types = codecInfo.getSupportedTypes();
for (String type : types) {
if (type.equalsIgnoreCase(mimeType)) {
return codecInfo;
}
}
}
return null;
}
MediaCodecInfo codecInfo = EncoderUtils.selectCodec("video/avc");
MediaCodec.createByCodecName(codecInfo.getName()).encoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
format
has the following keys
"color-format" -> {Integer@17131} 21
"i-frame-interval" -> {Integer@17133} 3
"mime" -> "video/avc"
"profile" -> {Integer@17136} 8
"width" -> {Integer@17138} 928
"bitrate-mode" -> {Integer@17140} 0
"bitrate" -> {Integer@17142} 3500000
"language" -> "eng"
"frame-rate" -> {Integer@17146} 12
"max-input-size" -> {Integer@17140} 0
"height" -> {Integer@17149} 1152
then i get the following exception:
Non-fatal Exception: android.media.MediaCodec$CodecException: Error 0x80001001
at android.media.MediaCodec.native_configure(MediaCodec.java)
at android.media.MediaCodec.configure(MediaCodec.java:1960)
at android.media.MediaCodec.configure(MediaCodec.java:1889)
at com.tomatedigital.lottogram.util.EncoderUtils.start(EncoderUtils.java:98)
at com.tomatedigital.lottogram.service.LottogramService$3.run(LottogramService.java:329)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
while the logcat prints:
I/OMXClient: IOmx service obtained
E/ACodec: [OMX.google.h264.encoder] configureCodec returning error -38
signalError(omxError 0x80001001, internalError -2147483648)
E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 3
E/MediaCodec: configure failed with err 0x80001001, resetting...
I/OMXClient: IOmx service obtained
W/AMessage: failed to deliver message as target handler 7 is gone.
E/ACodec: [OMX.google.h264.encoder] configureCodec returning error -38
signalError(omxError 0x80001001, internalError -2147483648)
E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 3
E/MediaCodec: configure failed with err 0x80001001, resetting...
I/OMXClient: IOmx service obtained
there is no such reference to 0x80001001 error anywhere i could find. what does it mean? how to solve it? does anyone have any clue?