Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaCodec Exception android.media.MediaCodec$CodecException: Error 0xfffffff4 on Repeated New Display Command #5798

Open
Shrey113 opened this issue Jan 27, 2025 · 3 comments

Comments

@Shrey113
Copy link

Image

Hi, I'm developing a Flutter app where I integrate ADB and scrcpy to create a new virtual display and launch specific Android apps. The command I use is as follows:

scrcpy -s {device_ip} --always-on-top --new-display --start-app=${selected_app} --window-title=${app['name']}

Initially, this works perfectly. However, after executing this command multiple times, I run into the following error: android.media.MediaCodec$CodecException: Error 0xfffffff4

Environment:
Device: oneplus 11
Android Version: 15
Scrcpy Version: 3.1
ADB Version: 35.0.2-12147458

Questions:

  1. Is there a limit on the number of virtual displays Android or scrcpy can handle?
  2. How can I ensure proper cleanup of virtual displays between commands?[must need 💯 ]
  3. Are there known issues with scrcpy and MediaCodec causing this error?

For reference, here’s my ADB-Scrcpy software repository : https://github.com/Shrey113/ADB-connection

@rom1v
Copy link
Collaborator

rom1v commented Jan 27, 2025

Is there a limit on the number of virtual displays Android or scrcpy can handle?

There is a limit on how much content your hardware encoder can encode simultaneously.

If you open 10 virtual displays in parallel, it means that your hardware encoder must encode 10 videos in parallel. It probably returns an error when its resources are exhausted.

How can I ensure proper cleanup of virtual displays between commands?

If you close scrcpy, the virtual displays are destroyed.

Are there known issues with scrcpy and MediaCodec causing this error?

No.

@Shrey113
Copy link
Author

Shrey113 commented Jan 27, 2025

Is there a way to use a single display and launch two or more apps in one scrcpy command, like scrcpy --new-display=1920x1080 --start-app=org.videolan.vlc + other app ? Or is there another way to use different encoders each time?"

@rom1v
Copy link
Collaborator

rom1v commented Jan 27, 2025

--start-app is just an helper to start an app, but you can do it at any time with adb (see commands in #5370).

But one convenient tip is to start a launcher: https://github.com/Genymobile/scrcpy/blob/master/doc/virtual_display.md#start-app

scrcpy --new-display=1920x1080 --no-vd-system-decorations --start-app=org.fossify.home

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants