bmcreations / scrcast

Drop-in Android Screen Recording Library
https://bmcreations.github.io/scrcast/
Apache License 2.0
212 stars 26 forks source link

Android 12 Issue - MediaRecorder "prepare failed" #58

Open panosx2 opened 2 years ago

panosx2 commented 2 years ago

Bug MediaRecorder crashes in Android 12 emulator on "prepare" call.

Logs

E/MediaRecorder: prepare failed: -2147483648
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: dev.bmcreations.scrcast.app, PID: 9916
    java.io.IOException: prepare failed.
        at android.media.MediaRecorder._prepare(Native Method)
        at android.media.MediaRecorder.prepare(MediaRecorder.java:1296)
        at dev.bmcreations.scrcast.internal.recorder.service.RecorderService.createRecorder(RecorderService.kt:159)
        at dev.bmcreations.scrcast.internal.recorder.service.RecorderService.access$createRecorder(RecorderService.kt:32)
        at dev.bmcreations.scrcast.internal.recorder.service.RecorderService$recordInternal$1.invokeSuspend(RecorderService.kt:227)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7839)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Screenshot image

kolyneh commented 2 years ago

Maybe it's just because of the video resolution you set.

OCCASS commented 1 year ago

hello, have you solved this problem?

jdevp commented 1 year ago

I'm having the same issue with Android 12. It works with Android 13 and Android 11 so it is not the parameter setting issues.

jdevp commented 1 year ago

Does anyone know if this issue is only with Android 12 on emulator? What about on Android 12 real device? It might have something to do with permissions.

kolyneh commented 1 year ago

Hi, you should have handled with permissions before using recorder.

I've had this problem on an Android 12 real device where I set odd number of resolution. Switching to even number of resolution solved it.

See my comment here for more info : https://github.com/Cap-go/capacitor-screen-recorder/issues/3#issuecomment-1232430246

jdevp commented 1 year ago

Hi, Thanks for confirming that it works on Android 12 real device. Yes, I do have all the permission granted at begining of my app. I tested on Android 10 and 13 real devices and they work as expected. On Tuesday, August 22, 2023 at 11:10:00 PM EDT, Kolyneh @.***> wrote:

Hi, you should have handled with permissions before using recorder.

I've had this problem on an Android 12 real device where I set odd number of resolution. Switching to even number of resolution solved it.

See my comment here for more info : Cap-go/capacitor-screen-recorder#3 (comment)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>