I have created a virtual alsa loopback device and trying to open a youtube link in google-chrome or chromium-browser and trying to send it's audio output to that virtual device. Then using ffmpeg I am trying to capture the audio. But no matter what I do, chrome or chromium always send audio output to default built-in speakers. If I open volume control panel and change the output of the application in playback section to loopback then it works. But my requirement to be able to do it programatically by telling the chrome to send audio on which device.
Following are the commands which I tried to make it happen:
google-chrome --window-position=0,0 --window-size=1920,1080 --alsa-output-device=alsa_output.1.analog-stereo.monitor -kiosk https://www.youtube.com/watch?v=LTbnmiXWs2k
google-chrome --window-position=0,0 --window-size=1920,1080 --alsa-output-device=hw:1,0 -kiosk https://www.youtube.com/watch?v=LTbnmiXWs2k
And following is the ffmpeg command which is working fine:
ffmpeg -f pulse -i alsa_output.1.analog-stereo.monitor -ac 1 -ar 16000 test.wav
Any help will be appreciated.
I have also suffered from the same problem, as Google didn't provide the complete format for ALSA output usage, so you can follow below procedure,
list out the plug hardware:
aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default:CARD=PCH
HDA Intel PCH, ALC662 rev3 Analog
Default Audio Device
sysdefault:CARD=PCH
HDA Intel PCH, ALC662 rev3 Analog
Default Audio Device
front:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev3 Analog
Front speakers
surround21:CARD=PCH,DEV=0
HDA Intel PCH, ALC662 rev3 Analog
2.1 Surround output to Front and Subwoofer speakers
Now select your plug hardware from the list and add its name to --alsa-output-device=
--alsa-output-device='plug:surround21'
so your complete command will look like below,
google-chrome --window-position=0,0 --window-size=1920,1080 --alsa-output-device='plug:surround21' -kiosk https://www.youtube.com/watch?v=LTbnmiXWs2k