Chromium --alsa-ouput-device flag not working

Viewed 7316

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.

2 Answers

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,

  1. 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
    
  2. 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

I faced the same problem while attempting to do the same. Here's what actually worked:

chrome (...) --alsa-output-device=hw:0,0
ffmpeg -f alsa -ac 2 -i hw:0,1,1 test.wav 

This has chrome using (card 0, device 0) for output, which is looped back to (card 0, device 1, substream 1). The format is --alsa-output-device=hw:card,device

The opposite also works:

chrome (...) --alsa-output-device=hw:0,1
ffmpeg -f alsa -ac 2 -i hw:0,0,1 test.wav 

Selecting the substream (e.g. --alsa-output-device=hw:0,1,4) is impossible. If capturing with ffmpeg just assume substream 1.

Related