This tool forwards audio from an Android 10 device to the computer. It does not require any root access. It works on GNU/Linux, Windows and macOS.
The purpose is to enable audio forwarding while mirroring with scrcpy. However, it can be used independently.
Update: scrcpy 2.0 now supports audio forwarding natively.
This application is a proof-of-concept. But as explained below, many apps are restricted and could not forward the audio.
- The Android device requires at least Android 10.
- VLC must be installed on the computer.
Download the latest release:
sndcpy-v1.1.zip
SHA-256:b045320ddddbc5a237d6d95213c664f03b2f46ef8bbfcef91c2d95644ed42bbcsndcpy-with-adb-windows-v1.1.zip
SHA-256:0b93c846f574df3f38f53eeee44b1a35b863a49465da8f5cd5b1b69a29305901
On Windows, for simplicity, take the second archive, which also contains
adb.
Alternatively, you could build the app.
Plug an Android 10 device with USB debugging enabled, and execute:
./sndcpyIf several devices are connected (listed by adb devices):
./sndcpy <serial> # replace <serial> by the device serial(omit ./ on Windows)
It will install the app on the device and start forwarding audio.
Press Ctrl+c in the terminal to stop (except on Windows, just disconnect the
device or stop capture from the device notifications).
VLC may print this error message once:
main stream error: connection error: Connection refused
It is "expected", just ignore it.
The sound continues to be played on the device. The volume can be adjusted independently on the device and on the computer.
You can also run sndcpy completely wirelessly over WiFi/LAN without needing ADB, USB debugging, or a cable. In this mode, the PC runs a Python receiver server, and you enter the PC's IP and port directly into the sndcpy Android app.
Start the Python server on your computer:
./sndcpy-server(By default, this plays audio via VLC on port 28200. You can also specify --pipewire or --pulseaudio backends).
- Build and install the
sndcpyAPK on your phone. - Open the
sndcpyapp on your device. - Enter your PC's IP address and the port (default:
28200). - Tap Start Streaming.
To stop streaming, either tap the Stop Streaming button in the app, click the notification action on your phone, or press Ctrl+C on the PC server terminal. The phone volume will automatically mute during streaming and restore to its original state when stopped.
To uninstall the app from the device:
adb uninstall com.rom1v.sndcpysndcpy may only forward audio from apps which do not prevent audio
capture. The rules are detailed in §capture policy:
- By default, apps that target versions up to and including to Android 9.0 do not permit playback capture. To enable it, include
android:allowAudioPlaybackCapture="true"in the app'smanifest.xmlfile.- By default, apps that target Android 10 (API level 29) or higher allow their audio to be captured. To disable playback capture, include
android:allowAudioPlaybackCapture="false"in the app'smanifest.xmlfile.
So some apps might need to be updated to support audio capture.
This is just a proof-of-concept, so it's far from perfect.
For example, jitter may cause VLC to automatically increase its buffering, causing an unacceptable delay:
main input error: ES_OUT_SET_(GROUP_)PCR is called too late (pts_delay increased to 377 ms)
In that case, just restart it.
The scripts sndcpy and sndcpy.bat use some default
values which can be overridden by environment variables.
ADB: the full path to theadbexecutableVLC: the full path to thevlcexecutableSNDCPY_APK: the full path tosndcpy.apkSNDCPY_PORT: the local port to forward to communicate with the device