Use phone as a microphone
- [x] I have checked that a similar feature request does not already exist.
I use my phone as a mic for my desktop by setting --audio-source=mic and then using Pipewire to connect it to a virtual source. It would be a lot easier to have some flag that does this automatically since it also plays whatever the mic picks up. Using --no-audio-playback doesn't work because I also disable video, so I also have to use Pipewire to disable the mic audio from being played.
@Grafcube would you mind sharing your Pipewire config for it?
would you mind sharing your Pipewire config for it?
Unfortunately I didn't make a config for it. I manually set it up using qpwgraph. I also don't do it anymore since I got a new microphone.
I don't get it working in Pipewire trying to use v4l2 (with pw-v4l2)...hopefully the maintainers have the motivation to switch away from v4l2 to Pipewire. There will probably another way to get it done...
would you mind sharing your Pipewire config for it?
Unfortunately I didn't make a config for it. I manually set it up using qpwgraph. I also don't do it anymore since I got a new microphone.
I would extremely grateful to you if you could share how did you do it with qpwgraph as I am trying and failing for hours.
How did you create virtual source?
would you mind sharing your Pipewire config for it?
Unfortunately I didn't make a config for it. I manually set it up using qpwgraph. I also don't do it anymore since I got a new microphone.
I would extremely grateful to you if you could share how did you do it with qpwgraph as I am trying and failing for hours.
How did you create virtual source?
I referred to this documentation to create the source. I don't remember if I used the exact same command or if I made changes to it but it should be a good starting point.
https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Virtual-Devices#create-a-source
Thanks a a lot! It set me on the right track!
+1ing this as it would be very convenient as I do not have an external microphone available.
How did you create virtual source?
pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=scrcpy_mic sink_properties=device.description="Scrcpy"
If it helps anyone, then you can easily connect it with qpwgraph. I am not sure how to do it in the command line as to create a script that does it all. If anyone shares a solution I would be grateful
YMMV, but here is another solution that I personally use:
pactl load-module module-pipe-source source_name="android" channels=2 format=s16 rate=48000 file=/tmp/mic_pipe(might need to tweak chan/format/rate based on format from the device)- Leave
parec -d android --raw > /dev/nullrunning in the bg (needed as this is a pipe - if nothing is consuming audio when scrcpy is started and stopped, you may get issues) scrcpy --no-video --no-window -N --audio-source=mic --audio-codec=raw --record-format=wav --record=/tmp/mic_pipe --audio-buffer=10 --audio-output-buffer=10(buffer values eyeballed, might need tweaking)
Thank you, I created a simple script that combines everything into one so it's easy
#!/usr/bin/sh
LATENCY=125
MODULE_ID=$(pactl load-module module-pipe-source source_name="Scrcpy" channels=2 format=16 rate=48000 file=/tmp/scrcpy_pipe)
parec --raw > /dev/null &
scrcpy --no-video --no-window --no-playback --audio-source=mic --audio-codec=raw --record-format=wav --record=/tmp/scrcpy_pipe --audio-buffer=$LATENCY --audio-output-buffer=10
pactl unload-module $MODULE_ID
I've set the latency high by default to avoid problems when the adb connection is over tcpip. Hope it helps somebody :)