I am trying to record my screen and the audio from my speakers using ffmpeg. This works fine on my tower PC with Ubuntu 18.04, but does not work using my thinkpad.
On the tower PC, this works fine using https://trac.ffmpeg.org/wiki/Capture/Desktop
(from https://trac.ffmpeg.org/wiki/Capture/Desktop ). But if I use the laptop, the same command records the sound from my microphone, which leads to heavily decreased sound quality.
arecord -l
returns
arecord -l
**** Liste der Hardware-Geräte (CAPTURE) ****
Karte 3: PCH [HDA Intel PCH], Gerät 0: ALC3232 Analog [ALC3232 Analog]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
and aplay -l
returns:
aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 2: HDMI [HDA Intel HDMI], Gerät 3: HDMI 0 [HDMI 0]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 2: HDMI [HDA Intel HDMI], Gerät 7: HDMI 1 [HDMI 1]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 2: HDMI [HDA Intel HDMI], Gerät 8: HDMI 2 [HDMI 2]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 2: HDMI [HDA Intel HDMI], Gerät 9: HDMI 3 [HDMI 3]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 2: HDMI [HDA Intel HDMI], Gerät 10: HDMI 4 [HDMI 4]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 3: PCH [HDA Intel PCH], Gerät 0: ALC3232 Analog [ALC3232 Analog]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Trying to set input like with ffmpeg -video_size 1368x768 -framerate 25 -f x11grab -i :0.0+0,0 -f alsa -i hw:0,0 -ac 2 output.mkv
(so hw:0,0
which should in my opinition be the default device) results in an error:
ALSA lib pcm_hw.c:1713:(_snd_pcm_hw_open) Invalid value for card
[alsa @ 0x55931414d3e0] cannot open audio device hw:0,0 (No such file or directory)
If I use https://trac.ffmpeg.org/wiki/Capture/ALSA#Recordaudiofromanapplication, so call sudo modprobe snd-aloop pcm_substreams=1
, add
# .asoundrc
pcm.!default { type plug slave.pcm "hw:Loopback,0,0" }
to /etc/asound.conf
, change my output device to so loopback via the settings GUI and run ffmpeg -f alsa -ac 2 -ar 44100 -i hw:Loopback,1,0 out.wav
it records the audio perfectly correct. But if I run ffmpeg -video_size 1368x768 -framerate 25 -f x11grab -i :0.0+0,0 -f alsa -ac 2 -ar 44100 -i hw:Loopback,1,0 output.mkv
, it just records the screen and some very rare small noises.
Is there a workaround for this, or is there another way to record my screen and the audio?