Recording screencasts in Ubuntu with FFmpeg

FFmpeg is a free and open source software that’s ideal for recording and converting audio and video. It has tons of configurations options and can be made to work with almost all of the widely used audio and video codecs out there. Now, I had installed Record My Desktop for capturing the screen of my Ubuntu machine but for some reason, every once in a while I was plagued with extremely low frame rates and the audio, video being out of sync. Although there are work-arounds for the said issues, none of them worked really well for me and I decided to give up on that gtk application. FFmpeg is a really fast and nifty tool for screen capturing and for a decent CPU configuration like mine (core i5 3210M), you can easily encode audio and video on the fly and it’s all a breeze. However, one thing that bothers a lot of people to get started with this amazing tool is the millions of options or presets available and to be able to find the right one for your hardware.

Iniially I installed FFmpeg from the official Ubuntu repositories and then tried to run a couple of commands I found on the forums and I always got errors like “This option is not available and cannot be parsed” after which I decided to compile it from source. There is a comprehensive and very well explained guide on how to do this on Ubuntu. Follow the steps mentioned and you should be good to go. After you have the directories and paths set up, I would recommend going through this forum or better still, the official documentation to get it working and experiment with different video encodings.

I did the same and through a lot of sources on github and youtube was ultimately able to come up with some simple configuration options for recording screencasts with ffmpeg. I have saved the configuration in a .extra bash script that I simple source in the .bashrc file whenever I open a terminal window.

Feel free to play around with the various options in the script above. There are functions for recording from a specific window or the entire screen of the computer either with pulse audio or the -hw option for hardware specific settings (which they don’t recommend). Pulse audio should work fine in most cases. I have been using this configuration for almost a month now and it works great even with an external mic plugged in, and I see amazing frame rate and audio sync with a simple command like (in the bash terminal):

I hope this quick tip gets you started with using ffmpeg for screen capture on Ubuntu with some command line action :D

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">