Giter Club home page Giter Club logo

sndcpy's Introduction

sndcpy (v1.1)

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.

Note

This application is a proof-of-concept. But as explained below, many apps are restricted and could not forward the audio.

Currently, the best solution to forward audio is to connect the device via bluetooth to the computer. It works for all apps, it does not suffer from additional limitations and works for basically all devices, contrary to sndcpy.

Requirements

  • The Android device requires at least Android 10.
  • VLC must be installed on the computer.

Get the app

Download the latest release:

On Windows, for simplicity, take the second archive, which also contains adb.

Alternatively, you could build the app.

Run the app

Plug an Android 10 device with USB debugging enabled, and execute:

./sndcpy

If 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.

Uninstall

To uninstall the app from the device:

adb uninstall com.rom1v.sndcpy

Apps restrictions

sndcpy 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's manifest.xml file.
  • 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's manifest.xml file.

So some apps might need to be updated to support audio capture.

Audio delay

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.

Environment variables

The scripts sndcpy and sndcpy.bat use some default values which can be overridden by environment variables.

  • ADB: the full path to the adb executable
  • VLC: the full path to the vlc executable
  • SNDCPY_APK: the full path to sndcpy.apk
  • SNDCPY_PORT: the local port to forward to communicate with the device

Blog post

sndcpy's People

Contributors

rom1v avatar practicalbutterfly5 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.