MediaCodec createInputSurface failed with -38
Asked Answered
T

0

2

I launch the grafika, a dialog turned out and said "Failed to generate cotent. Some features may be unavailable. Can't use input surface with software codec: OMX.google.h264.encoder"

Then I click OK button and entered the continuous caputure activity, the app crashed.

My device infomation is as follows:

Model: Lenovo A560

Android version: 4.3

I am sure this is the key log:

    06-29 21:27:50.267 E/OMXMaster(17347): A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
06-29 21:27:50.267 I/SoftAVCEncoder(17347): Construct SoftAVCEncoder
06-29 21:27:50.267 D/ResourceManager(17347): findUseCaseAndSetParameter - mime=video/avc,componentName=OMX.google.h264.encoder,isDecoder=0
06-29 21:27:50.267 D/ResourceManager(17347): findUseCaseAndSetParameter-useCase =,useCaseFlag = 0, codecFlags = 0
06-29 21:27:50.267 D/ResourceManager(17347): mime = video/avc, componentName = OMX.google.h264.encoder, isDecoder = 0
06-29 21:27:50.267 D/ResourceManager(17347): software video useCase =
06-29 21:27:50.267 I/ACodec (17347): setupVideoEncoder succeeded
06-29 21:27:50.267 E/OMXNodeInstance(17347): createInputSurface requires AndroidOpaque color format
06-29 21:27:50.267 E/ACodec (17347): [OMX.google.h264.encoder] onCreateInputSurface returning error -38
06-29 21:27:50.267 W/MediaCodec(17347): createInputSurface failed, err=-38
06-29 21:27:50.277 D/KeyguardUpdateMonitor( 1249): sendKeyguardVisibilityChanged(true)
06-29 21:27:50.277 D/KeyguardUpdateMonitor( 1249): handleKeyguardVisibilityChanged(1)
06-29 21:27:50.277 D/AndroidRuntime(17347): Shutting down VM
06-29 21:27:50.277 W/dalvikvm(17347): threadid=1: thread exiting with uncaught exception (group=0x415ac8b0)
06-29 21:27:50.297 E/AndroidRuntime(17347): FATAL EXCEPTION: main
06-29 21:27:50.297 E/AndroidRuntime(17347): java.lang.IllegalStateException
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.media.MediaCodec.createInputSurface(Native Method)
06-29 21:27:50.297 E/AndroidRuntime(17347): at com.android.grafika.CircularEncoder.(CircularEncoder.java:124)
06-29 21:27:50.297 E/AndroidRuntime(17347): at com.android.grafika.ContinuousCaptureActivity.surfaceCreated(ContinuousCaptureActivity.java:383)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.SurfaceView.updateWindow(SurfaceView.java:571)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.SurfaceView.access$000(SurfaceView.java:86)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:833)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1860)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.Choreographer.doFrame(Choreographer.java:532)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.os.Handler.handleCallback(Handler.java:730)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.os.Handler.dispatchMessage(Handler.java:92)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.os.Looper.loop(Looper.java:137)
06-29 21:27:50.297 E/AndroidRuntime(17347): at android.app.ActivityThread.main(ActivityThread.java:5136)
06-29 21:27:50.297 E/AndroidRuntime(17347): at java.lang.reflect.Method.invokeNative(Native Method)
06-29 21:27:50.297 E/AndroidRuntime(17347): at java.lang.reflect.Method.invoke(Method.java:525)
06-29 21:27:50.297 E/AndroidRuntime(17347): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
06-29 21:27:50.297 E/AndroidRuntime(17347): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-29 21:27:50.297 E/AndroidRuntime(17347): at dalvik.system.NativeStart.main(Native Method)
06-29 21:27:50.317 I/ActivityManager( 1249): Notify an ApplicationCrash

How to fix this issue?

Thagard answered 29/6, 2016 at 13:40 Comment(7)
It's failing to open a hardware codec, so it's opening a software one instead. The software codec implementation in 4.3 wasn't compatible with Surface input, so it fails to generate the videos. One way this can happen is if something else on the device has opened the hardware video codecs, and didn't release them when paused.Lebel
@Lebel I did not run anything else. I am sure that nothing has opened the hardware video codecs.Thagard
@Lebel According to this #30506375 OMX.google.h264.encoder is a software encoder, is it a software encoder on any android devices?Thagard
I believe OMX.google.h264.encoder is always the software implementation. Later versions of Android have improved implementations. I don't know why mediacodec would be picking that if a hardware codec is available. Several of the Activities rely on Surface input to a video encoder, so I'd expect them to fail in similar ways.Lebel
@Lebel I use MediaCodecList to enumerate all avc encoders on the device and find this codec "OMX.qcom.video.encoder.avc", So I use MediaCodec.createByCodecName("OMX.qcom.video.encoder.avc"); to get this encoder, but this encoder turn out a decoder from logcat.Thagard
@Lebel I reboot the phone, the error disappeared. The API createEncoderByType return encoder with name OMX.qcom.video.encoder.avc instead of OMX.google.h264.encoderThagard
Sounds like mediaserver thought the encoders were unavailable for some reason. If not in use, maybe failure to initialize? I haven't seen this particular failure mode myself.Lebel

© 2022 - 2024 — McMap. All rights reserved.