报错如下:
2022-12-15 16:26:22.386 3687-3728/com.example.mediacodec E/AndroidRuntime: FATAL EXCEPTION: Thread-2
Process: com.example.mediacodec, PID: 3687
java.lang.IllegalStateException
at android.media.MediaCodec.native_setCallback(Native Method)
at android.media.MediaCodec.setCallback(MediaCodec.java:4606)
at com.example.mediacodec.VideoDecodeThread.run(VideoDecodeThread.java:81)
If the client intends to use the component in asynchronous mode, * a valid callback should be provided before {@link #configure} is called.
原因:setCallback设置的时机不对,setCallback应该在MediaCodec.configure();之前调用