Cannot figure out how to make FFMPEG stream the audio from my speakers

My full command (though the relevant parts of it are the first bits)

ffmpeg -f alsa -ac 2 -i hw:0,0,0 -acodec aac -video_size 1920x1080 -framerate 60 -f x11grab -i :0.0 -c:v h264_nvenc -tier high -spatial-aq 1 -multipass fullres -tune:v hq -rc:v constqp -qp 17 -preset:v p7 -color_range tv -colorspace bt2020_ncl -color_primaries bt709 -color_trc gamma22 -pix_fmt yuv444p -movflags +faststart -vf "hue=h=-3:s=0.98, eq=gamma=0.98:contrast=0.99" output.mp4

I’ve tried a bunch of things like

hw:0,0
plughw:0,0
hw:Loopback,0,0
hw:Loopback,1,0
pulse
default

even tried

ffmpeg -f pulse -ac 2 -i alsa_output.pci-0000_00_1f.3.analog-stereo

for hw:0,0 - plughw:0,0 - hw:0,0,0 it will record the sound from my microphone, but i don’t want it to record the sound from my mic i want it to record the osund from my speakers/headphones and i’m at my wit’s end trying to figure htis out.

Relevant info:

System:
  Kernel: 5.17.9-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.1.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-5.17-x86_64
    root=UUID=ade649ba-48e8-4bd1-9e1c-7878c6f77246 rw quiet
    sysrq_always_enabled=1 mitigations=off nowatchdog pci=noaer
    cpufreq.default_governor=performance apparmor=1 security=apparmor
    udev.log_priority=3 acpi_osi=! acpi_osi=Linux "acpi_osi=Windows 2009"
    nogpumanager intel_idle.max_cstate=1 i915.enable_gvt=1 i915-enable_fbc=1
    pcie_port_pm=off iommu=pt intel_iommu=on kvm.ignore_msrs=1
    rd.driver.pre=vfio-pci default_hugepagesz=1G hugepagesz=1G hugepages=0
    transparent_hugepage=never
  Desktop: KDE Plasma v: 5.24.5 tk: Qt v: 5.15.4 wm: kwin_x11 vt: 1 dm: SDDM
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: Micro-Star product: GE75 Raider 8SE v: REV:1.0
    serial: <superuser required> Chassis: type: 10 serial: <superuser required>
  Mobo: Micro-Star model: MS-17E2 v: REV:1.0 serial: <superuser required>
    UEFI: American Megatrends v: E17E2IMS.11A date: 05/19/2020
Battery:
  ID-1: BAT1 charge: 39.0 Wh (100.0%) condition: 39.0/53.4 Wh (73.1%)
    volts: 12.0 min: 10.9 model: MSI BIF0_9 type: Li-ion serial: N/A
    status: full
  Device-1: hidpp_battery_0
    model: Logitech MX Vertical Advanced Ergonomic Mouse serial: <filter>
    charge: 50% (should be ignored) rechargeable: yes status: N/A
Memory:
  RAM: total: 31.19 GiB used: 14.2 GiB (45.5%)
  RAM Report:
    permissions: Unable to run dmidecode. Root privileges required.
CPU:
  Info: model: Intel Core i7-8750H bits: 64 type: MT MCP arch: Coffee Lake
    family: 6 model-id: 0x9E (158) stepping: 0xA (10) microcode: 0xF0
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 1.5 MiB desc: 6x256 KiB
    L3: 9 MiB desc: 1x9 MiB
  Speed (MHz): avg: 3899 high: 3903 min/max: 800/4100 scaling:
    driver: intel_pstate governor: performance cores: 1: 3903 2: 3899 3: 3900
    4: 3900 5: 3900 6: 3900 7: 3900 8: 3900 9: 3896 10: 3900 11: 3900 12: 3900
    bogomips: 52815
  Flags: 3dnowprefetch abm acpi adx aes aperfmperf apic arat
    arch_capabilities arch_perfmon art avx avx2 bmi1 bmi2 bts clflush clflushopt
    cmov constant_tsc cpuid cpuid_fault cx16 cx8 de ds_cpl dtes64 dtherm dts
    epb ept ept_ad erms est f16c flexpriority flush_l1d fma fpu fsgsbase fxsr
    ht hwp hwp_act_window hwp_epp hwp_notify ibpb ibrs ida intel_pt invpcid
    invpcid_single lahf_lm lm mca mce md_clear mmx monitor movbe mpx msr mtrr
    nonstop_tsc nopl nx pae pat pbe pcid pclmulqdq pdcm pdpe1gb pebs pge pln
    pni popcnt pse pse36 pts rdrand rdseed rdtscp rep_good sdbg sep smap smep
    ss ssbd sse sse2 sse4_1 sse4_2 ssse3 stibp syscall tm tm2 tpr_shadow tsc
    tsc_adjust tsc_deadline_timer vme vmx vnmi vpid x2apic xgetbv1 xsave
    xsavec xsaveopt xsaves xtopology xtpr
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: vulnerable
  Type: mds status: Vulnerable; SMT vulnerable
  Type: meltdown status: Vulnerable
  Type: spec_store_bypass status: Vulnerable
  Type: spectre_v1 status: Vulnerable: __user pointer sanitization and
    usercopy barriers only; no swapgs barriers
  Type: spectre_v2 status: Vulnerable, IBPB: disabled, STIBP: disabled
  Type: srbds status: Vulnerable
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] vendor: Micro-Star MSI
    driver: i915 v: kernel ports: active: eDP-1 empty: DP-1,HDMI-A-1
    bus-ID: 00:02.0 chip-ID: 8086:3e9b class-ID: 0300
  Device-2: NVIDIA TU106M [GeForce RTX 2060 Mobile] vendor: Micro-Star MSI
    driver: nvidia v: 510.73.05 alternate: nouveau,nvidia_drm non-free: 515.xx+
    status: current (as of 2022-05) arch: Turing pcie: gen: 1 speed: 2.5 GT/s
    lanes: 16 link-max: gen: 3 speed: 8 GT/s bus-ID: 01:00.0
    chip-ID: 10de:1f11 class-ID: 0300
  Display: x11 server: X.Org v: 21.1.3 compositor: kwin_x11 driver: X:
    loaded: modesetting,nvidia alternate: fbdev,nouveau,nv,vesa gpu: i915
    display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22")
    s-diag: 582mm (22.93")
  Monitor-1: eDP-1 model: AU Optronics 0x409d built: 2018 res: 1920x1080
    hz: 144 dpi: 128 gamma: 1.2 size: 382x215mm (15.04x8.46")
    diag: 438mm (17.3") ratio: 16:9 modes: 1920x1080
  OpenGL: renderer: Mesa Intel UHD Graphics 630 (CFL GT2) v: 4.6 Mesa 22.0.4
    direct render: Yes
Audio:
  Device-1: Intel Cannon Lake PCH cAVS vendor: Micro-Star MSI
    driver: snd_hda_intel v: kernel alternate: snd_soc_skl,snd_sof_pci_intel_cnl
    bus-ID: 00:1f.3 chip-ID: 8086:a348 class-ID: 0403
  Device-2: NVIDIA TU106 High Definition Audio vendor: Micro-Star MSI
    driver: snd_hda_intel v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 16
    link-max: gen: 3 speed: 8 GT/s bus-ID: 01:00.1 chip-ID: 10de:10f9
    class-ID: 0403
  Sound Server-1: ALSA v: k5.17.9-1-MANJARO running: yes
  Sound Server-2: PulseAudio v: 15.0 running: no
  Sound Server-3: PipeWire v: 0.3.51 running: yes
Network:
  Device-1: Intel Cannon Lake PCH CNVi WiFi
    vendor: Rivet Networks Killer Wireless-AC 1550i Wireless driver: iwlwifi
    v: kernel bus-ID: 00:14.3 chip-ID: 8086:a370 class-ID: 0280
  IF: wlo1 state: up mac: <filter>
  IP v4: <filter> type: dynamic noprefixroute scope: global
    broadcast: <filter>
  IP v6: <filter> type: noprefixroute scope: link
  Device-2: Qualcomm Atheros Killer E2500 Gigabit Ethernet
    vendor: Micro-Star MSI driver: alx v: kernel pcie: gen: 1 speed: 2.5 GT/s
    lanes: 1 port: 3000 bus-ID: 05:00.0 chip-ID: 1969:e0b1 class-ID: 0200
  IF: enp5s0 state: down mac: <filter>
  WAN IP: <filter>
Bluetooth:
  Message: No bluetooth data found.
Logical:
  Message: No logical block device data found.
RAID:
  Message: No RAID data found.
Drives:
  Local Storage: total: 2.07 TiB used: 1.88 TiB (90.4%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Kingston
    model: RBUSNS8154P3256GJ size: 238.47 GiB block-size: physical: 512 B
    logical: 512 B speed: 15.8 Gb/s lanes: 2 type: SSD serial: <filter>
    rev: E8FK11.C temp: 46.9 C scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 vendor: Western Digital
    model: WDS100T2B0B-00YS70 size: 931.51 GiB block-size: physical: 512 B
    logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter> rev: 00WD
    scheme: GPT
  ID-3: /dev/sdb maj-min: 8:16 vendor: KingSpec model: ACSC4M1TS25
    size: 953.87 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 4H scheme: GPT
  Message: No optical or floppy data found.
Partition:
  ID-1: / raw-size: 238.17 GiB size: 233.38 GiB (97.99%)
    used: 190.74 GiB (81.7%) fs: ext4 dev: /dev/nvme0n1p2 maj-min: 259:2
    label: N/A uuid: ade649ba-48e8-4bd1-9e1c-7878c6f77246
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 288 KiB (0.1%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
    label: NO_LABEL uuid: B822-64D2
  ID-3: /run/media/rabcor/KingSpec raw-size: 953.87 GiB
    size: 953.4 GiB (99.95%) used: 898.26 GiB (94.2%) fs: xfs dev: /dev/sdb1
    maj-min: 8:17 label: N/A uuid: 7081018e-cce8-4d7d-b093-bb681ff46b8e
  ID-4: /run/media/rabcor/WD raw-size: 931.51 GiB size: 931.51 GiB (100.00%)
    used: 831.85 GiB (89.3%) fs: f2fs dev: /dev/sda1 maj-min: 8:1
    label: Western Digital uuid: ae81d12d-6838-4833-b47b-8dd120364382
Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default)
  ID-1: swap-1 type: file size: 8 GiB used: 0 KiB (0.0%) priority: -2
    file: /swapfile
Unmounted:
  Message: No unmounted partitions found.
USB:
  Hub-1: 1-0:1 info: Hi-speed hub with single TT ports: 16 rev: 2.0
    speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
  Device-1: 1-2:2 info: Logitech Unifying Receiver type: Keyboard,Mouse,HID
    driver: logitech-djreceiver,usbhid interfaces: 3 rev: 2.0 speed: 12 Mb/s
    power: 98mA chip-ID: 046d:c52b class-ID: 0300
  Device-2: 1-3:5 info: Logitech MX Vertical Advanced Ergonomic Mouse
    type: Mouse,Keyboard,HID driver: hid-generic,usbhid interfaces: 3 rev: 2.0
    speed: 12 Mb/s power: 500mA chip-ID: 046d:c08a class-ID: 0300
    serial: <filter>
  Device-3: 1-7:3 info: Realtek RTS5129 Card Reader Controller
    type: <vendor specific> driver: rtsx_usb,rtsx_usb_ms,rtsx_usb_sdmmc
    interfaces: 1 rev: 2.0 speed: 480 Mb/s power: 500mA chip-ID: 0bda:0129
    class-ID: ff00 serial: <filter>
  Device-4: 1-9:4 info: SteelSeries ApS KLC type: HID
    driver: hid-generic,usbhid interfaces: 2 rev: 2.0 speed: 12 Mb/s
    power: 300mA chip-ID: 1038:1122 class-ID: 0300
  Hub-2: 2-0:1 info: Super-speed hub ports: 8 rev: 3.1 speed: 10 Gb/s
    chip-ID: 1d6b:0003 class-ID: 0900
Sensors:
  System Temperatures: cpu: 62.0 C pch: 50.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 424 Uptime: 13h 23m wakeups: 18 Init: systemd v: 250
  tool: systemctl Compilers: gcc: 12.1.0 clang: 13.0.1 Packages: pacman: 1722
  lib: 500 Shell: Bash v: 5.1.16 running-in: konsole inxi: 3.3.16
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC1220 Analog [ALC1220 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC1220 Digital [ALC1220 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 2: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
$ pactl list sinks short
41      alsa_output.pci-0000_00_1f.3.analog-stereo      PipeWire        s32le 2ch 44100Hz       RUNNING
52      easyeffects_sink        PipeWire        float32le 2ch 44100Hz   RUNNING
3590    alsa_output.platform-snd_aloop.0.analog-stereo  PipeWire        s32le 2ch 48000Hz       SUSPENDED

$ pactl list sources short
41      alsa_output.pci-0000_00_1f.3.analog-stereo.monitor      PipeWire        s32le 2ch 44100Hz       IDLE
42      alsa_input.pci-0000_00_1f.3.analog-stereo       PipeWire        s32le 2ch 48000Hz       SUSPENDED
52      easyeffects_sink.monitor        PipeWire        float32le 2ch 44100Hz   RUNNING
53      easyeffects_source      PipeWire        float32le 2ch 44100Hz   SUSPENDED
3590    alsa_output.platform-snd_aloop.0.analog-stereo.monitor  PipeWire        s32le 2ch 48000Hz       SUSPENDED
3591    alsa_input.platform-snd_aloop.0.analog-stereo   PipeWire        s32le 2ch 48000Hz       SUSPENDED

Please help.

pactl list sources short
ffmpeg -f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -t 30 out.wav

changed the command and edited op :slight_smile:

your suggested command did not work though :frowning: it produced no audio.

Also tried with:
alsa_output.platform-snd_aloop.0.analog-stereo.monitor
alsa_output.platform-snd_aloop.0.analog-stereo
easyeffects_sink.monitor
easyeffects_sink

same deal for all of them, no sounds get recorded.

Edit: I managed to find out where the problem lies, i turned off EasyEffects and then audio does get recorded.

Edit2: Apparently the solution to this is to use -f alsa instead of -f pulse, and indeed with -f alsa -i plughw:0,0 i do get to record mic audio, but that’s not the audio i want to record.

Asked on the git for easyeffects, apparently the solution is to exclude lavf (the stream created by ffmpeg for recordoing audio) in easyeffects.

This behavior is supposed to become automated in the next release of easyeffects too.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.