Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upForward audio #14
Forward audio #14
Comments
|
Adding this would really making streaming games would so much better. So far all the other existing solutions kinda suck. |
|
Is it even possible without a custom rom? |
|
I just implemented a PoC (separated of scrcpy) to enable audio forwarding from the device to the computer: aoa-audio. On Debian stable, it "works": the device sound is played on the computer. This is quite manual though, and several issues must be solved before something similar could be implemented in scrcpy. Any help is welcome |
|
May it be possible to use AudioRecord api server side? |
|
|
|
I may be wrong but here is an example of what I thought: https://github.com/tzutalin/ReadPCMData/blob/master/src/com/da/readpcmtest/MainActivity.java Sorry I should have added this on my previous comment. |
|
Oh, you're right, I missed the |
|
Arf, just calling Note that |
|
Yes... :( Audio support is really tricky :/ |
|
Even from an app, the source
(while it works with |
|
Hi, I would like to share with you my work-in-progress branch: I implemented it, and it works fine for me! I would like early feedbacks so that any major issue can be fixed. Requirements
How toInstall libusb:
Checkout the
Use a debug build to report problems:
Run with audio forwarding enabled:
The audio should be forwarded. When closed, the audio forwarding may not be totally disabled. It may require to restart the current audio track (in VLC for example). If it is not sufficient, unplug the device. At worst (but it should not be necessary), disable/enable USB debugging. How it worksScrcpy connects to the device over USB to send AOA requests so that the computer becomes an "USB audio accessory" for the device. This creates a new audio input source on the computer (which can be seen in PulseAudio for example). Scrcpy records this input source and immediately plays it to the default output source. Thank you for your feedbacks. |
|
In theory, it should now also work on Windows (in MSYS2/mingw64), with the
However, when it try to communicate to open the device over USB on Windows,
I have no idea how to get the permissions granted. Any ideas? |
|
On macOS you can install libusb with the following command: On a MBP 15, macOS 10.13.3 it is not working. I start the app while a podcast is playing on the device. This behaviour is 100% reproducible on my side. Here are the command line output:
|
|
Thank you for the test
It did not select the right input source, either because none were created, either because for now it just selects the last one, assuming it's the most recent (so it should probably be the input source from the device). I'll check that. Thank you. |
|
For your information I've done 2 tests one with a headset connected to the computer and another one without any headset plugged in. Good luck |
|
@eyal-lezmy I investigated on Mac, and it appears that enabling "audio accessory" on the device does not create a new audio input source on the computer. So unfortunately, I think that the feature will be Linux-only… I updated the branch to reject the input source if its name does not contain the device model (so that it does not open the built-in microphone for example). |
|
Ok so heres a wholly stupid question. Would it work via the Linux environment in windows 10? |
You tell me |
|
What is the plan of merging this excellent feature into the main branch? |
|
Did you test it? Does it work correctly for you? There are several problems:
So for now, I don't merge it. Maybe I could, mentionning that it is very experimental... |
|
Hi, thanks for the package! I've been enjoying it a lot On my Archlinux machine, I have both libusb and libusb-compat installed besides the dependencies already listed in the AUR package for scrcpy. The testing scrcpy pacakge was compiled with the pre-built server.jar. When attempting to start scrcpy audio forwarding with my Nokia6.1 (Android 8.1, July 1st 2018 patch), the program exits with the following error message:
Without the --forward-audio flag, the program runs fine. |
|
@yimuchen Could you test manually with pactl and ffplay:
|
|
@rom1v I'm a bit new to writing this sort of code, Can you help me with how I should get the string for my device, the The output of pactl is:
On a side note, as a test, I edited the |
Sorry, I copied incomplete instructions I kept in some textfile. Instead, follow the steps I wrote in the README of aoa-audio. |
|
@rom1v Thanks for instructions! I think the issue that I have is that the udev rules for my phone isn't available yet. The vendor/product ID under |
|
looks like this work fine for android 8 but not android 9 |
|
@rom1v did you give up? |
@barfin Can you specify which usbaudio solution are you referring to here? It's become a long thread; so difficult to spot. |
this one right here but a temporary solution I'm using right has nothing to do with adb, scrcpy,etc |
I abandon usbaudio, because AOA is obsolete since Android 8. However, I plan to implement audio forwarding via the Playback Capture API. See #1407 (comment) But I work on this project (scrcpy) on my free time (which is, basically, my sleep time), and there are always other things to do. I wish I had more time to work on this. But I will do it. |
Do you notice any lag? |
|
for now i use scrpy for display, and vysor for sound, it must be on same wifi. work fine for recording. its kinda laggy for live streaming because using same wifi for upload and playing game simultaneously. using Xiaomi A2 (no jack audio port :( ) |
Does Vysor transmit the device sound, or just records the microphone? |
yes it has input lag but it's better than nothing |
|
People are starting to look for other solutions and abandon scrcpy |
Vysor, with the recent update now transmits sound internally. It wasn't able to do this back then. Well it does, but on very limited devices. |
Is scrcpy faster in terms of screen mirror compared to vysor? The latest update made in possible to record/transmit internal audio. I haven't tried doing just audio on vysor. Not even sure thats possible but if it is, would like to know how. |
|
anyone found an audio solution for galaxy note 10+ when has no earphone jack? |
|
I implemented a separate tool (it's a PoC, but it works) to forward audio for Android 10: |
is there any solution for android 9? usbaudio is too old for android 9 and sndcpy is too new |
hello ... I followed your guide but when I click send on the cmd after authorizing from the phone, I am waiting for connection I start any game and the audio is heard only on the mobile phone .. you have some solution to recommend |
|
so i implemented this and made changes in the sndcpy.bat file vlc --demux rawaud --play-and-exit tcp://localhost:%SNDCPY_PORT% so now my vlc opens up and playlist has the item tcp://localhost:2800 |
|
I use the Bluetooth Audio Receiver app from the microsoft store to forward my phone audio to PC thanks to the new Windows 10 May 2020 Update (2004). You need a bluetooth adapter and a playback device that supports A2DP SINK for this to work. To make this possible you just need to pair your device with your PC and connect it using the app. I tested it and it works really well. Here's the link to the app if you're interested. |
|
@HillBird this is great. Can I know which Bluetooth adapter you are using? it should be 5.0? |
As long as you have a bluetooth feature available on your pc, you could give it a shot :) |
|
@HillBird Thank you! It works. Earlier I was getting audio with noise and crackles. I just turned off the WiFi and problem gone. I think there is some interference on WiFi and Bluetooth channels as both use 2.4GHz frequency. Any thoughts on this? |
Yeah when I play games on my phone, the noise sounds a little bit delayed and crackled too. |
|
These are all workarounds which don't solve the issue at hand |
|
Actually it worked on my redmi note 8, windows 10 2004, using bluetooth audio receiver app! |

Directing audio to the client would be pretty neat.
Currently you can accomplish the same thing by plugging a 3.5mm cable into the mic or line-in on the computer. Some manufacturers are dropping headphone ports though.