Forwarding audio from Android devices
In order to support audio forwarding in scrcpy, I first implemented an experimentation on a separate branch (see issue #14). But it was too hacky and fragile to be merged (and it does not work on all platforms).
So I decided to write a separate tool: USBaudio.
It works on Linux with PulseAudio.
How to use USBaudio
First, you need to build it (follow the instructions).
Plug an Android device. If USB debugging is enabled, just execute:
If USB debugging is disabled (or if multiple devices are connected), you need to
specify a device, either by their serial or vendor id and product_id (as
The audio should be played on the computer.
If it’s stuttering, try increasing the live caching value (at the cost of a higher latency):
Note that it can also be directly captured by OBS:
How does it work?
USBaudio executes 3 steps successively:
- It enables audio accessory on the device (by sending AOA requests via libusb), so that the audio is forwarded over USB. If it works, PulseAudio (or ALSA) on the computer should detect a new audio input source.
- It retrieves the PulseAudio input source id associated to the Android device (via libpulse).
- It execs VLC to play audio from this input source.
Note that enabling audio accessory changes the USB device product id, so it will close any adb connection (and scrcpy). Therefore, you should enable audio forwarding before running scrcpy.
To only enable audio accessory without playing:
The audio input sources can be listed by:
$ pactl list short sources ... 5 alsa_input.usb-LGE_Nexus_5_05f5e60a0ae518e5-01.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
Use the number (here
5) to play it with VLC:
Alternatively, you can use ALSA directly:
$ cat /proc/asound/cards ... 1 [N5 ]: USB-Audio - Nexus 5 LGE Nexus 5 at usb-0000:00:14.0-4, high speed
Use the device number (here
1) as follow:
If it works manually but not automatically (without
-n), then please open an
It does not work on all devices, it seems that audio accessory is not always well supported. But it’s better than nothing.