Forward 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 |
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! |
hey guys.. i need help with sndcpy.. it error me every time |
Although just use This don't really work with things like discord, because it expect video and audio from same program. Which isn't the case currently. Any workaround for this? |
What phone and OS? |
Xiaomi note 8 pro and 10 |
what is the specific error? |
doesnt work sndcpy |
|
so everyone got it work except me.. okay.. |
@DiSavi I just pointed out the post explaining how to solve your problem (remove |
still dont get it.. never mind.. |
I've been testing sndcpy for a while now and it works well enough. That said, it's a separate command from scrcpy while the guiscrcpy still only use usbaudio from what I see. I would like to see an implementation on guiscrcpy, especially if we could streamline the apk install for sndcpy so as to eliminate the delay in checking / reinstalling sndcpy.apk (which sometimes need me to do the sndcpy command a few times before the stream prompt appear). Something that can automate the process on guiscrcpy would be very nice. |
Maybe I'm missing something here, but I don't understand this issue. All I have to do to forward audio while scrcpy is running is to pair my phone and computer via bluetooth. And in the bluetooth settings on my phone, where it lists the computer it is paired with, make sure "Use for Phone Audio/ Media Audio" are both checked. That's it, now audio from my phone is played through my laptop speakers, or any speakers I connect to my laptop. I don't have to open anything or do anything extra on my laptop either. Is this not an option for y'all? |
guiscrcpy is a separate project. For the integration in scrcpy, read https://blog.rom1v.com/2020/06/audio-forwarding-on-android-10/#integration-in-scrcpy |
Ah, right, sorry about that. Didn't see which tab I was on. Still, thank you for the reply, I hope to see it eventually when you have the time for it. |
It works but the audio is either behind or ahead of the display |
Also scrcpy works via wifi which has more range than bluetooth |
Also, BT doesn't work well when you have few devices in range, and especially several device on the same BT radio/controller. |
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.
The text was updated successfully, but these errors were encountered: