Step 1: Install PulseAudio Volume Control and ffmpeg
Search your distribution’s software repository to install them. On a typical Ubuntu like OS the terminal command would be
$ sudo apt-get install pavucontrol ffmpeg
Step 2: Record
Use following command to record your desktop.
ffmpeg -f alsa -i default -f x11grab -s 1366x768 -r 30 -i :0.0 -sameq filename.avi
x11grab: Record the desktop
s: Size of the recording area (For true HD it would be 1920×1080 i.e 1080p). However, it depends upon your monitor resolution. Anything greater will fail, Use Displays to find the resolution.
r: Frame rate. If you intend to record game play videos, adjust the frame rate until you don’t get choppy output.
-f and -i: These two variable are for audio. If default does not work, use “pulse” instead.
Note: If the recording fails, try to change the format. E.g mpg, mkv etc.
Step 3: Switching between internal audio and microphone
While recording, open PulseAudio Volume Control (pavucontrol) and in the Recording section, switch between microphone and Internal audio (see figure below). Use “Built-in Audio Analog Stereo” for recording from microphone and “Monitor of Built-in Audio Analog Stereo” to record sound playing in your computer. Make sure you are actually recording the desktop to change these options, ffmpeg option does not show up in pavucontrol until you start the recording.
Step 4: Create a script
Create a script, say recorddesktop.sh, so that you don’t have to remember it all the time. Create the bash file in a directory you use to add scripts e.g ~/bin (/home/username/bin) and add it to PATH variable in .bashrc as (export PATH=$PATH:~/bin). Content of that file would be something like this (Adjust resolution and other parameters as you prefer).
#!/bin/bash # Example recorddesktop.sh output.avi STR="@" FILENAME="out.avi" if [ $STR ]; then FILENAME="$@" else echo "No file name specified, using out.avi" FILENAME="out.avi" fi #FILENAME="$(echo $FILENAME | sed 's/\ /\\ /g')"; echo "Recording into $FILENAME ..."; ffmpeg -f alsa -i default -f x11grab -s 1366x768 -r 30 -i :0.0 -sameq "$FILENAME"