Screen capture of a selected window with ffmpeg in Ubuntu

After some trial and error and reading some other posts, I finally manage to capture screencast of a selected window with ffmpeg under 10.04. I am using the native ffmpeg from ubuntu and so recompiling is not needed. The command I’m using is as below.

ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 15 \
 -s $(xwininfo -frame | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+') \
 -i :0.0+$(xwininfo -frame | grep -oEe 'Corners: +\+[0-9]+\+[0-9]+' \
 | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/' ) \
 -acodec pcm_s16le -vcodec mpeg4 -sameq -y out.mkv ;

The command will capture a particular window. After running the command, one has to click the window one wants to capture twice (getting size and then getting location).

Leave a Reply

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