Evanescent Thoughts

Evanescent Thoughts

Making a Screencast in Linux !!

with 4 comments

Making small utilities in Linux is fun . There are a hell lot of small tools in linux that when you put together , make cool things. I made a few this week when I was bored after watching “House” continuosly.
There are three things I am gonna put up here .

  • Making a screencast of your desktop .
  • Making a recursive video
  • Opening a man page in a pdf viewer  .

1. Making screencast of your desktop :

The main motivation behind this is Topcoder and Petr(yeah the target red coder … he is an Alien too ) . Petr used to screencast his topcoder matches to the world .  So I started looking into the net for tools to capture my desktop as a video file ( not that I wanted to screencast my topcoder matches . Would be pathetic 😛 )  .  So I came across a couple of GUI’s for windows and then Abhilash was out looking for the same thing ( may be his screencast would be interesting . He types at an amazing 90 wpm 🙂 ) . By this time I had got my hands on this tool ffmpeg which had the option to grab the video from anything . So little bit of googling lead me to a site which gave me this

 ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq ~/Desktop/out.mpg

But sadly this didnt work for me . And then  I went on to read the man pages of ffmpeg and this is when i found it buggy to read the man page of a big command in terminal and  I went on to create a small utility to open man pages in evince (later on this ) . But this command didnt work for me and gave some error in the input format.  Reading the man pages, -f is for forcing  the source format  which is “grabbing the X11 display ” ( the desktop of X actually ) . The -s argument is for the output video resolution size and found that setting it to wxga was the mistake  . I changed it to suit my resolution which is xga . -r is for the frame rate in fps .  -i gives the input file which in our case is the :0.0 display . -sameq says the ffmpeg to use the same video quality as produced by the source. You might wanna remove this incase you want a video file of small size. And finally this command worked :).

ffmpeg -f x11grab -s xga -r 25 -i :0.0 -sameq ~/Desktop/1.mpg

Now , this is not an easy command to write and I wont be needing it often . So , I thought why not make a script out of it .  So put the following in a file and named it as “capturevideo” and changed the command to

ffmpeg -f x11grab -s xga -r 25 -i :0.0 -sameq ~/Desktop/$1.mpg

so that I can get the output file name from the command line . Now all I had to do was  export my PATH variable to make it search my /home/Sathya/Tools folder where I have kept all these small tools . Opened my .bashrc file and added

export PATH=$PATH:/home/Sathya/Tools

and then finally did a

chmod u+x /home/Sathya/Tools/capturevideo .

And Bingo !!! capturevideo sample  created a sample video of my desktop operations . I actually made a recursive video out of it 🙂 .

2. Making a Recursive video using Step 1 :

Actually I stumbled upon this by mistake . Follow the following steps to make a recursive video .

  1. Run the above capturevideo command .
  2. Open the video file that is being created while the command is still running and put it to full screen
  3. Keep watching till you feel you have recursed enough in the video 🙂 .

Now press a ‘q’ in the prompt of capturevideo and enjoy watching the recursive video . Here is a screen shot of my recursive video  :). This will create a linear recursion . In case you wanna double up, open it in two players and capture .


3. Opening a man page directly in your pdf viewer.

I  had already blogged about a part of this here on how to convert  a man page to pdf here . Basically man has a -t option which creates the ps form of  the man pages . I redirect that to a file and store it as a post script file and use the ps2pdf utlity to convert the file to pdf. Till now is what i usually used to do . But this was getting irritating since each time I had to delete the files created after I am done viewing the page.  Hence this is what I did .

man -t $1 > /tmp/$1.ps
ps2pdf /tmp/$1.ps /tmp/$1.pdf
evince /tmp/$1.pdf
rm -rf /tmp/$1.ps /tmp/$1.pdf

Now we  store this in a file called manpdf and then do the following to give it permissions to execute .

chmod u+x /home/Sathya/Tools/manpdf

And from now on , doing a manpdf ls would directly open the man page in evince and after you are done reading the man page , it  will delete the temporary files created in the /tmp folder. Is’nt that really simple 🙂

Any more easy utilities are welcome as comments 🙂 .


Written by Sathya Narayanan

March 28, 2009 at 8:04 pm

4 Responses

Subscribe to comments with RSS.

  1. havent you heard of istanbul??

    Anshu Prateek

    April 11, 2009 at 8:10 pm

    • hmmm.. not until today 🙂 .. but i wud prefer this 🙂 …

      Sathya Narayanan

      April 11, 2009 at 8:37 pm

  2. I follow your posts for quite a long time and should tell you that your articles always prove to be of a high value and quality for readers.

    Vince Delmonte

    April 15, 2009 at 3:08 pm

  3. This looks like an awful lot of work when recordMyScreen (which is based on Istanbul) does the same thing.


    June 2, 2009 at 4:38 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: