myrao / ScreenRecorder

A demo of Android screen recorder, no root but SDK version should more than Android 5.0 API 21.
497 stars 174 forks source link

镜头推流直接崩溃! #38

Open addriumruss opened 3 years ago

addriumruss commented 3 years ago

华为荣耀30S手机, 安卓10, 屏幕推流成功了,然后测试镜头推流,直接崩了,异常如下:

E/ACodec: [OMX.hisi.video.encoder.avc] configureCodec returning error -22 signalError(omxError 0x80001001, internalError -22) E/MediaCodec: Codec reported err 0xffffffea, actionCode 0, while in state 3 E/MediaCodec: configure failed with err 0xffffffea, resetting...

E/AndroidRuntime: FATAL EXCEPTION: main Process: net.yrom.screenrecorder, PID: 31907 java.lang.RuntimeException: Unable to start activity ComponentInfo{net.yrom.screenrecorder/net.yrom.screenrecorder.ui.activity.CameraActivity}: java.lang.IllegalArgumentException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3863) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4042) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2450) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8285) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055) Caused by: java.lang.IllegalArgumentException at android.media.MediaCodec.native_configure(Native Method) at android.media.MediaCodec.configure(MediaCodec.java:2023) at android.media.MediaCodec.configure(MediaCodec.java:1951) at net.yrom.screenrecorder.ui.activity.CameraActivity.prepareEncoder(CameraActivity.java:138) at net.yrom.screenrecorder.ui.activity.CameraActivity.onCreate(CameraActivity.java:89) at android.app.Activity.performCreate(Activity.java:8085) at android.app.Activity.performCreate(Activity.java:8073) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3836)

请问怎么解决? 谢谢!

myrao commented 3 years ago

这个项目有点早了,当时 camera 这块的实现应该是有点问题的,你可以把 camera 的原始帧重新用 MediaCodec 实现一次编码过程,拿到 yuv 再进行推流,MediaCodec 的实现流程可以参照其他开源库,谷歌的这个开源库 grafika 没记错就有很多 sample code

addriumruss commented 3 years ago

重新编码不太会搞啊

myrao commented 3 years ago

看看 grafika 吧,肯定对你有帮助的,关键代码: MediaCodec 和 BufferInfo

addriumruss commented 3 years ago

好的大佬 只能硬着头皮试试了 大佬有空补一下就好~