JayXT / RecordAudioOutput

A custom script to record audio output in GNU/Linux.
GNU General Public License v3.0
10 stars 1 forks source link

Records sometimes from microphone #2

Open PSeitz opened 3 months ago

PSeitz commented 3 months ago

I'm using pipewire with manjaro.

The script selects 56. Family 17h/19h HD Audio Controller Analog Stereo [vol: 0.70] from wpctl, which is sometimes the microphone. The monitor source is missing from wpctl, but is listed in pactl (1512).

Changing the script line to this fixes it in my case:

targetSink=$(pactl list sources short | grep 'alsa_output.pci-0000_65_00.6.analog-stereo.2.monitor' | awk '{print $1}')

pactl & wpctl Output

➜  pactl list sources short
1512    alsa_output.pci-0000_65_00.6.analog-stereo.2.monitor    PipeWire        s32le 2ch 48000Hz       RUNNING
1513    alsa_input.pci-0000_65_00.6.analog-stereo.2     PipeWire        s32le 2ch 48000Hz       SUSPENDED
1520    alsa_input.usb-046d_HD_Pro_Webcam_C920-02.analog-stereo PipeWire        s16le 2ch 32000Hz       SUSPENDED
2453    alsa_output.pci-0000_65_00.1.hdmi-stereo.2.monitor      PipeWire        s32le 2ch 48000Hz       SUSPENDED
➜  wpctl status
PipeWire 'pipewire-0' [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, cookie:2186267655]
 └─ Clients:
        31. xdg-desktop-portal                  [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1367]
        32. WirePlumber                         [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1657]
        40. WirePlumber [export]                [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1657]
        41. pipewire                            [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1880]
        43. plasmashell                         [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1488]
        44. libcanberra                         [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1488]
        51. KDE Power Management System         [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1563]
        75. kded6                               [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1410]
        84. Plasma PA                           [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1488]
        85. Firefox                             [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1955]
        86. Firefox                             [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1955]
        87. WEBRTC VoiceEngine                  [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:6345]
        88. Firefox                             [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:1955]
        89. WEBRTC VoiceEngine                  [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:6345]
        91. Chromium input                      [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:6402]
       100. electron                            [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:208432]
       120. wpctl                               [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:590263]
       126. Brave input                         [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:390140]
       128. Chromium input                      [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:496444]
       129. Steam                               [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:464652]
       130. Steam Voice Settings                [1.0.7, pascal@pascal-rogzephyrusg14ga403uvga403uv, pid:464652]

Audio
 ├─ Devices:
 │      63. Family 17h/19h HD Audio Controller  [alsa]
 │      74. C920 PRO HD Webcam                  [alsa]
 │     106. Rembrandt Radeon High Definition Audio Controller [alsa]
 │  
 ├─ Sinks:
 │      52. Rembrandt Radeon High Definition Audio Controller Digital Stereo (HDMI) [vol: 0.40]
 │  *   56. Family 17h/19h HD Audio Controller Analog Stereo [vol: 0.70]
 │  
 ├─ Sources:
 │      77. C920 PRO HD Webcam Analog Stereo    [vol: 1.00]
 │  *   79. Family 17h/19h HD Audio Controller Analog Stereo [vol: 1.00]
 │  
 ├─ Filters:
 │  
 └─ Streams:
        90. Firefox                                                     
             93. output_FL       > ALC285 Analog:playback_FL    [init]
             95. output_FR       > ALC285 Analog:playback_FR    [init]
        96. Firefox                                                     
             97. output_FL       > ALC285 Analog:playback_FL    [init]
             99. output_FR       > ALC285 Analog:playback_FR    [init]
       104. Firefox                                                     
            105. output_FL       > ALC285 Analog:playback_FL    [init]
            115. output_FR       > ALC285 Analog:playback_FR    [init]
       110. Firefox                                                     
            111. output_FL       > ALC285 Analog:playback_FL    [init]
            112. output_FR       > ALC285 Analog:playback_FR    [init]
       119. Firefox                                                     
            116. output_FR       > ALC285 Analog:playback_FR    [active]
            118. output_FL       > ALC285 Analog:playback_FL    [active]
       121. Firefox                                                     
            101. output_FL       > ALC285 Analog:playback_FL    [init]
            113. output_FR       > ALC285 Analog:playback_FR    [init]
       134. Firefox                                                     
            127. output_FL       > ALC285 Analog:playback_FL    [init]
            132. output_FR       > ALC285 Analog:playback_FR    [init]

Video
 ├─ Devices:
 │      55. HD Pro Webcam C920                  [libcamera]
 │      57. HD Pro Webcam C920                  [v4l2]
 │      58. HD Pro Webcam C920                  [v4l2]
 │      59. USB2.0 FHD UVC WebCam               [v4l2]
 │      64. USB2.0 FHD UVC WebCam: USB2.0 F     [libcamera]
 │      65. USB2.0 FHD UVC WebCam               [v4l2]
 │      70. USB2.0 FHD UVC WebCam               [v4l2]
 │      71. USB2.0 FHD UVC WebCam               [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sources:
 │      42. USB2.0 FHD UVC WebCam (V4L2)       
 │      67. HD Pro Webcam C920 (V4L2)          
 │      72. HD Pro Webcam C920                 
 │  *   76. USB2.0 FHD UVC WebCam (V4L2)       
 │  
 ├─ Filters:
 │  
 └─ Streams:

Settings
 └─ Default Configured Devices:
JayXT commented 3 months ago

@PSeitz, sorry for the late response and thank you for the useful input. In the PipeWire version of the script I rely on wpctl output as the primary way to get information about audio devices. Not sure whether pactl is or always will be available in the future of Linux audio.

As I see there's source 79 for the same device and that one indeed might be a microphone. However, in your example "56. Family 17h/19h HD Audio Controller Analog Stereo [vol: 0.70]" belongs to sinks category in other words it should be an output device. If 56 is selected as the source for recording, it should record output at least if there are no bugs in pw-record, or other components of PipeWire stack.