scrcpy: Not work audio streaming on android 11
Environment
- OS: Windows 11
- scrcpy version: scrcpy 2.0
- installation method: Windows release…
- device model: Redmi Note 8T
- Android version: 11
Describe the bug The sound just doesn’t work. When you try to make it forcibly this happens
PS Programs\scrcpy-win64-v2.0> .\scrcpy-console.bat -d --require-audio
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
C:\Users\bropi\Programs\scrcpy-win64-v2.0\scrcpy-server: 1 file pushed, 0 skipped. 62.6 MB/s (52867 bytes in 0.001s)
[server] INFO: Device: Xiaomi Redmi Note 8T (Android 11)
INFO: Renderer: direct3d
INFO: Initial texture: 1080x2336
[server] ERROR: Failed to start audio capture
[server] ERROR: On Android 11, it is only possible to capture in foreground, make sure that the device is unlocked when starting scrcpy.
WARN: Demuxer 'audio': stream explicitly disabled by the device
ERROR: Demuxer error
WARN: Killing the server... ```
Please do not post screenshots of your terminal, just post the content as text instead.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (1 by maintainers)
Commits related to this issue
- Make 3 attempts to start AudioRecord On Android 11, a fake popup must be briefly opened to make the system think that the shell app is in the foreground so that audio may be recorded. Making the she... — committed to Genymobile/scrcpy by rom1v a year ago
- Make 3 attempts to start AudioRecord On Android 11, a fake popup must be briefly opened to make the system think that the shell app is in the foreground so that audio may be recorded. Making the she... — committed to Genymobile/scrcpy by rom1v a year ago
- Make 3 attempts to start AudioRecord On Android 11, a fake popup must be briefly opened to make the system think that the shell app is in the foreground so that audio may be recorded. Making the she... — committed to Genymobile/scrcpy by rom1v a year ago
- Increase attempts to start AudioRecord Making the shell app foreground (specific for Android 11) may take more than 300ms on some devices, so increase the number of attempts from 3 to 5 (separated by... — committed to Genymobile/scrcpy by rom1v a year ago
Yep. Working on my phone. Thanks. I think we’ll wait for feedback from other users, and close this issue
After 5 hours of misunderstandings with Linux I finally installed it. Delay of 300 (units, seconds, whatever) is working
I just saw all these branches. What a horror)
I implemented 3 attempts with 100ms before each, so that on most devices, it will work within 100ms (so the popup is not visible for too long), but on others it will still work: bc82e340d751da8fd1903f93ee00b455a7e6a904
Here is a full build for win64:
scrcpy-win64.zip
SHA-256: scrcpy-win64-v2.0-21-g85c45c5f5.zip
Please tell me if it works for you.
Alright, with a delay of 250 it seems to work fine every time. I haven’t tried any other values, though, but I might later.
EDIT: After a bunch of restarts I did manage to get it to fail. 300 might be better then.
It doesn’t look hard, I’m going to try it now