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

No audio forwarding on Android 12 #4884

Open
2 tasks done
dduynam opened this issue Apr 24, 2024 · 8 comments
Open
2 tasks done

No audio forwarding on Android 12 #4884

dduynam opened this issue Apr 24, 2024 · 8 comments

Comments

@dduynam
Copy link

dduynam commented Apr 24, 2024

Environment

  • OS: Android
  • scrcpy version: 2.4
  • installation method: Windows release
  • Android version: 12

Describe the bug
I used scrcpy version of 2.4 to capture the screen and audio. But only the screen is shown but audio. Audio still is output at device.
Please refer to the log print for more information. Thank you.

E:\00.Work\11.AIVI-2\Tools\scrcpy-win32-v2.4>scrcpy -Vverbose
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  e2f74983                        device  xx
DEBUG: Device serial: e2f74983
DEBUG: Using server (portable): E:\00.Work\Tools\scrcpy-win32-v2.4\scrcpy-server
E:\00.Work\Tools\scrcpy-win32-v2.4\scrcpy-server... file pushed, 0 skipped. 50.7 MB/s (69007 bytes in 0.001s)
[server] INFO: Device: xx (Android 12)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Using video encoder: 'c2.qti.avc.encoder'
INFO: Renderer: direct[server] DEBUG: Display: using SurfaceControl API
3d
DEBUG: Trilinear filtering disabled (not an OpenGL renderer)
DEBUG: Using icon (portable): E:\00.Work\Tools\scrcpy-win32-v2.4\icon.png
DEBUG: Demuxer 'video': starting thread
DEBUG: Demuxer 'audio': starting thread
INFO: Texture: 1920x720
DEBUG: [Audio] Buffering threshold exceeded, skipping 240 samples
DEBUG: [Audio] Buffering threshold exceeded, skipping 960 samples
DEBUG: [Audio] Buffering threshold exceeded, skipping 960 samples
DEBUG: [Audio] Buffering threshold exceeded, skipping 480 samples
DEBUG: [Audio] Buffering threshold exceeded, skipping 480 samples
VERBOSE: [Audio] Buffering: target=2400 avg=4929.599609 cur=5520 compensation=-2529
VERBOSE: input: touch [id=finger] down position=1466,540 pressure=1.000000 action_button=000001 buttons=000001
VERBOSE: input: touch [id=finger] up   position=1466,540 pressure=0.000000 action_button=000001 buttons=000000
VERBOSE: [Audio] Buffering: target=2400 avg=4422.644043 cur=4387 compensation=-2022
VERBOSE: [Audio] Buffering: target=2400 avg=3962.702637 cur=3877 compensation=-1562
VERBOSE: [Audio] Buffering: target=2400 avg=3576.951660 cur=3002 compensation=-1176
VERBOSE: [Audio] Buffering: target=2400 avg=3311.704102 cur=3664 compensation=-911
VERBOSE: [Audio] Buffering: target=2400 avg=3113.251221 cur=3433 compensation=-713
VERBOSE: [Audio] Buffering: target=2400 avg=2939.896729 cur=2772 compensation=-539
VERBOSE: [Audio] Buffering: target=2400 avg=2814.116943 cur=2635 compensation=-414
VERBOSE: [Audio] Buffering: target=2400 avg=2720.497070 cur=2529 compensation=-320
VERBOSE: [Audio] Buffering: target=2400 avg=2632.031494 cur=2928 compensation=-232
VERBOSE: [Audio] Buffering: target=2400 avg=2585.509277 cur=2869 compensation=-185
VERBOSE: [Audio] Buffering: target=2400 avg=2548.860840 cur=2822 compensation=-148
VERBOSE: [Audio] Buffering: target=2400 avg=2513.368408 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2504.741943 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2502.830322 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2501.891357 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2510.543701 cur=2784 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2517.902344 cur=2784 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2536.364746 cur=2784 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2541.127441 cur=2784 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2545.099121 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2533.673340 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2529.946777 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2517.253418 cur=2304 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2531.992432 cur=2784 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2541.165039 cur=2784 compensation=0
VERBOSE: input: key down code=113 repeat=0 meta=203000
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=113 repeat=0 meta=200000
VERBOSE: [Audio] Buffering: target=2400 avg=2541.799316 cur=2784 compensation=0
VERBOSE: [Audio] Buffering: target=2400 avg=2562.664551 cur=2784 compensation=0
VERBOSE: input: key down code=113 repeat=0 meta=203000
VERBOSE: input: key down code=113 repeat=1 meta=203000
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: [Audio] Buffering: target=2400 avg=2553.977051 cur=2304 compensation=0
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: [Audio] Buffering: target=2400 avg=2554.090820 cur=2304 compensation=0
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: input: key down code=31 repeat=0 meta=203000
VERBOSE: input: key up   code=31 repeat=0 meta=203000
VERBOSE: [Audio] Buffering: target=2400 avg=2547.879150 cur=2304 compensation=0
VERBOSE: input: key up   code=113 repeat=0 meta=200000
VERBOSE: [Audio] Buffering: target=2400 avg=2543.529785 cur=1824 compensation=0
DEBUG: User requested to quit
DEBUG: quit...
DEBUG: Demuxer 'video': end of frames
DEBUG: Demuxer 'audio': end of frames
DEBUG: Receiver stopped
DEBUG: Server disconnected
DEBUG: Server terminated

@rom1v
Copy link
Collaborator

rom1v commented Apr 24, 2024

Do you have some headphones connected?

@dduynam
Copy link
Author

dduynam commented Apr 24, 2024

You mean headphones connected to my PC or the device running Android.
Actually, my PC is connecting to one headphone device. and the Android device does not.

Updated: I tried to disconnect and retry to scrcpy. But it still doesn't work.

@rom1v
Copy link
Collaborator

rom1v commented Apr 24, 2024

Weird, which device is it?

Does it work with another device?

@dduynam
Copy link
Author

dduynam commented Apr 24, 2024

It's an Android-based embedded project. Is there any abnormal point captured on log?
If it's fine, then I suspect there is a security mechanism on that device to limit the audio forwarding.

@rom1v
Copy link
Collaborator

rom1v commented Apr 24, 2024

I suspect there is a security mechanism on that device to limit the audio forwarding.

Or something not implemented related to REMOTE_SUBMIX capture.

Can you connect bluetooth earphones to this device? If so, is the audio correctly played in the earphones?

@dduynam
Copy link
Author

dduynam commented Apr 24, 2024

Does it work with another device?

Yes... I have tested it with my Android phone. The audio is output at PC normally.

Can you connect bluetooth earphones to this device? If so, is the audio correctly played in the earphones?

Actually, cannot connect BT earphones to this device. It doesn't support as an A2dpSource Audio gateway.

FYI,
I just used your sndcpy (https://github.com/rom1v/sndcpy) and it works, but the audio latency was very high (around 1-2s).
As followed the info from your old issues, there's a big improvement in streaming audio delay in scrcpy as of v.2.1

@dduynam
Copy link
Author

dduynam commented Apr 25, 2024

@rom1v
For the workaround of sndcpy, the audio is output at PC but high latency and cannot forward media sources (Radio, USB) except BT Audio and system sound.
Is there different between sndcpy or scrcpy v.2? or basically sndcpy is embedded in scrcpy, using VLC for streaming audio.

@rom1v
Copy link
Collaborator

rom1v commented Apr 25, 2024

Is there different between sndcpy or scrcpy

They are very different.

Sndcpy was just a proof-of-concept using the playback capture API introduced in Android 10. It installs a real app (an .apk) on the device (contrary to scrcpy which executes a Java main to get shell permissions, but cannot have a real Android Context necessary for some APIs).

One major drawback of this playback capture API is that it lets Android apps decide if they can be captured or not. In practice, many apps were just not captured.

For simplicity, the PoC just used VLC to play the stream, so there was absolutely no mechanism to regulate latency (so it's easy to get a lot of latency).

Scrcpy uses another mechanism to capture audio (which does not require an app, see #3757). And of course, there is a latency compensation mechanism (see an overview in this blog post).

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