scrcpy: ERROR: Exception on thread Thread[main,5,main]

I have this message and then nothing happens. I’m running v1.7 both 32 and 64 bits. I’m using Android 8.1

scrcpy-server.jar: 1 file pushed. 2.7 MB/s (19346 bytes in 0.007s)
ERROR: Exception on thread Thread[main,5,main]
android.media.MediaCodec$CodecException: Error 0xfffffc0e
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:1956)
        at android.media.MediaCodec.configure(MediaCodec.java:1885)
        at com.genymobile.scrcpy.ScreenEncoder.configure(ScreenEncoder.java:158)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:68)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:28)
        at com.genymobile.scrcpy.Server.main(Server.java:110)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:316)
Exit due to uncaughtException in main thread:
ERROR: Could not open video stream
INFO: Initial texture: 1080x2336
WARN: Cannot terminate server
Press any key to continue...

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 31

Most upvoted comments

OK, Solved, don’t worry. Just went in the CMD to the folder where scrcpy is unziped, then use this: scrcpy -m 1080 and it works!!!

Android 12 requires scrcpy >= 1.18.

  1. use the latest scrcpy version
  2. if it still happens, it’s #3051

[server] INFO: Device: Xiaomi M2101K7AG (Android 12) INFO: Renderer: direct3d INFO: Initial texture: 1080x2400 WARN: Device disconnected [server] ERROR: Exception on thread Thread[main,5,main] java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3535) at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:114) at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:95) at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:61) at com.genymobile.scrcpy.Server.scrcpy(Server.java:80) at com.genymobile.scrcpy.Server.main(Server.java:255) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:363)

help me pls

First of all, v1.13 is very old. Use the latest version.

tried to put the command andit didn’t worked

Which command? pip3? You might need to install it (sudo apt install python3-pip).

I have the latest version

20.04.4 LTS

That’s very old 😉

I guess you are using an old version of Ubuntu.

In that case, uninstall the package from the distribution, and install manually: https://github.com/Genymobile/scrcpy/blob/master/BUILD.md#simple (you might need to use a newer version of meson than the one from the distro too, so sudo pip3 install meson)

–max-size 1080…change 1080 to your desired value

Go to settings of Android Studio -> ADB Wi-Fi -> then in Command-line flags Write: --max-size 1080 --always-on-top --show-touches

This doesn’t give much clues and we end up googling the error and reading the answer here.

Maybe a simple message like: …

This is already what scrcpy does: https://github.com/Genymobile/scrcpy/commit/8a694a97855333849976bea5e558eaa45add0168

This problem is that the error code can only be read since API 23 (Android 6), and I guess your device is API 21 (Android 5), so it can’t know which exact error it is.