How to Screencast From the Command Line in Linux

When it comes to screencasting (recording video of your desktop), most people will think of a desktop software with proper user interface. For Linux, we have covered several tools such as Kazam, Screenr and Screentoaster. What many people do not know is that you can screencast from the command line as well, via FFMPEG. It’s a simple (and very long) configurable command that lets you record video of your desktop.

FFMPEG are available in most distro’s repositories. Install it with the command below:




Arch Linux

Can’t find it in your distributions’ repositories? You may need to download it directly from and install it that way.

Before screencasting can happen, the command needs to be customized to suit your needs. The command below has no specified resolution, will screencast at 30 FPS and outputs the file in the .MKV format.

Find your screen’s native resolution and replace the YxZ with it (e.g: 1920×1080). Not happy with only 30 frames per second? Change -r 30 to your desired FPS.

Screencasting is as simple as pasting the command above (one you’ve modified it to suit you) into a terminal. While the command is running, you’ll be able to know exactly what FFMPEG is doing. You’ll notice something similar to the image below.


That’s basically it. With that long command, you’re screencasting. Want to stop the capture? Press the “q” key or close the terminal window entirely. It’ll print out information about the recording that just finished. This information is great as it can tell you everything that happened during the process.

Like all applications, FFMPEG taps into Pulse Audio. This means it can be manipulated. By default, all applications recording take sound input via the default sound device. If your computer has a microphone (or one plugged in), FFMPEG will automatically record sound from it and add it to your screencast. If this is something you don’t want, you can change it.

Install Pulse Audio Volume Control. It’s a very popular tool and thus is in most popular distro repositories. In Ubuntu (or Ubuntu-based distros), you can install it with the following command:

For other distro, you just have to search for “pavucontrol” in your package manage and install it. Once installed, start an FFMPEG screencast and open “Pulse Audio Volume Control.” Inside the tool, click on the recording tab.


In the recording tab, click the Built-in Audio Analog Stereo button. It’ll bring up a selection menu.


In the menu, select Monitor of Built-in Audio Analog Stereo. This will make FFMPEG record your system sound instead of your computer’s microphone. This trick is great if you’re looking to record gameplay or anything that requires audio.

FFMPEG is an amazing tool that can do many, many things. Screencasting is just one of its abilities. Few alternatives to it can even capture high-quality footage while offering great performance. The command line is awesome because with it you can be as precise as you want. You can specify what you want to accomplish and see it appear before your eyes.