Monday, January 02, 2012

Screencast of particular window in Ubuntu using ffmpeg

When you want to record the screen output, there have been some software good to use [1]. However, I found none of them can properly record the zone in which a C++ program produced video stream combining webcam input and OpenGL objects.

After some trials, I found an useful solution [2] and made some modifications. It is a shell script that uses ffmpeg to record the video content of target window.


echo -e "Usage: bash $0 outputfile\nClick on the window to be recorded."

size=$(xwininfo -frame | awk '/geometry/ {print $2}')
offset=$(echo $size | awk -F + '{print $2","$3}')

ffmpeg -f alsa -ac 2 -ab 192k -i pulse -f x11grab -s $size -r 30 -i :0.0+$offset -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 $1
[1] Such as recordMyDesktop and xvidcap
[2] Run FFMPEG with x11grab

No comments:

Post a Comment