Capturing ONLY desktop audio with ffmpeg

Solution 1:

pavucontrol

enter image description here

  1. Install pavucontrol.
  2. Start recording with ffmpeg (see example commands below).
  3. Start pavucontrol.
  4. Go to the Recording tab and you'll find ffmpeg or Lavf56.15.102 (or similar) listed there.
  5. Change audio capture from Internal Audio Analog Stereo to Monitor of Internal Audio Analog Stereo.

Now it should record system and application audio instead of the microphone.

This setting will be remembered. The next time you want to capture with ffmpeg, it will automatically start recording system audio. If you want to revert this, use pavucontrol again to change back to microphone input.

The text above was adapted from HOWTO: Screencasting on Linux.

example ffmpeg commands

audio only

ffmpeg -f pulse -i default output.wav

with screen capture

ffmpeg -f x11grab -video_size 1360x768 -framerate 30 -i :0.0 -f pulse -i default -preset ultrafast -crf 18 -pix_fmt yuv420p out.mkv

Solution 2:

You can also record to compressed MP3 (with a bit rate of your choice) such as:

ffmpeg -f alsa -ac 2 -i default -acodec libmp3lame -ab 320k ouput.mp3