Screencast with FFmpeg

August 10, 2014

One of the best things with the Linux command line is that you happen to find a utility for almost everything you’d ever want to do with your computer. Last year I was looking for a screencast software supporting Linux. I found a couple few but upon trying I didn’t like them. Then I came across a post on where I found a FFmpeg one-liner to capture my screen. That looked awesome & I tried. Fell in love instantly. Since then whenever I need to capture my screen for a short video I just shoot FFmpeg with the following parameters:

ffmpeg -f x11grab -r 25 -s 1280x768 -i :0.0 -vcodec libx264 -preset ultrafast -crf 0 screencast-01.mkv

This tool is useful when you quickly need to capture a tweak and explain someone over the internet. Instead of having multiple screenshots it’s worth capturing a 2 mins screencast.


To capture the screen with sound, we add the alsa part to the line as follows:

ffmpeg -f alsa -ac 2 -i default -itsoffset 00:00:00.5 -f x11grab -r 25 -s 1280x768 -i :0.0 -vcodec libx264 -preset ultrafast -crf 0 screencast-02.mkv

FFmpeg comes handy when converting videos as well. Here’s another one-liner when I have to convert videos taken with my Nikon Coolpix camera.

ffmpeg -i DSCN0245.AVI -vcodec libx264 -crf 22 -strict -2 video-01.mp4
Screencasts I made using FFmpeg