航行在蓝天的蚂蚱 2025-09-19 14:43 采纳率: 0%
浏览 21

Android小米14 硬件编码报错

java.lang.IllegalStateException: Invalid to call at Released state; only valid in executing state

                                                                                                    at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
                                                                                                    at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:4066)
                                                                                                    at com.frog.record.camera.function.CodeCFunctionKt.handleOutputBuffer(SourceFile:21)
                                                                                                    at com.frog.record.camera.encoder.video.VideoRecorder1.drainEncoder(SourceFile:61)
                                                                                                    at com.frog.record.camera.encoder.video.VideoRecorder1.encodeFrame$lambda$2(SourceFile:89)
                                                                                                    at com.frog.record.camera.encoder.video.VideoRecorder1.b(SourceFile:1)
                                                                                                    at com.frog.record.camera.encoder.video.a.run(SourceFile:1)
                                                                                                    at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                    at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    at android.os.Looper.loopOnce(Looper.java:249)
                                                                                                    at android.os.Looper.loop(Looper.java:337)
                                                                                                    at android.os.HandlerThread.run(HandlerThread.java:85)

2025-09-19 14:41:15.224 7441-8378 ActivityManagerWrapper com.miui.home E getRecentTasksForceIncludingTaskIdIfValid: getRecentTasks: size=1

  • 写回答

5条回答 默认 最新

  • 阿里嘎多学长 2025-09-19 14:43
    关注

    阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程

    硬件编码报错解决方案

    根据你提供的信息,问题 seems 是由于 MediaCodec 在 Released 状态下被调用造成的。

    你可以尝试检查以下几点:

    1. 确保 MediaCodec 在正确的状态: 使用 isReleased()isInitialized() 等方法检查 codec 的状态。
    2. 重写 release() 和 init() 方法: 重写 release()init() 方法,确保 codec 正确释放和初始化。
    3. 正确使用 MediaMuxer: 确保使用 MediaMuxer 的时机和方式正确。

    以下是核心代码(示意),你可以根据自己的实现进行调整:

    // 在初始化 codec 之前进行检查和释放
    if (mediaCodec != null && !mediaCodec.isReleased()) {
        mediaCodec.release();
        mediaCodec = null;
    }
    
    // 初始化 codec
    mediaCodec = MediaCodec.createEncoderByType("video/avc");
    mediaCodec.configure(mimeType, null, null, MediaCodecConfig.FLAG_ENCODE);
    
    // 释放 codec
    if (mediaCodec != null && !mediaCodec.isReleased()) {
        mediaCodec.release();
        mediaCodec = null;
    }
    

    希望这些信息能够帮助你解决问题。

    评论

报告相同问题?

问题事件

  • 创建了问题 9月19日