How to capture video from an application with the sound?

Don’t know if it’s by default, but in my Xubuntu, only a sound from the microphone can be recorded. This link came with help: How to do the same with a recordmydesktop application:

Create .asoundrc file in Your home directory like in mentioned webpage:

# .asoundrc
# uncomment to record audio from applications. uncomment afterwards to
# restore default Alsa settings:
# pcm.!default { type plug slave.pcm "hw:Loopback,0,0" }

When the last line is uncommented, there will be no sound for every application launched from that moment, because generally it’s redirected to the recording output.

Load the snd_aloop module:

modprobe snd-aloop pcm_substreams=1

Launch an application, from which the video will be captured. Check it’s window id with xwinfo and by pointing application’s window:

xwininfo | grep 'id:'

Invoke recordmydesktop with hw:Loopback,1,0 as a sound device. PID will be needed to send signal to stop recording (‘& echo$!’)

recordmydesktop --windowid [application wid] --device
hw:Loopback,1,0 --v_quality 45 --s_quality 7 --overwrite & echo $!

Stop recording by sending SIGTERM signal:

kill -s SIGTERM [recordmydesktop PID]

Uncomment line in .asoundrc file to restore Alsa settings.