<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Prashanth Ellina &#187; ubuntu</title>
	<atom:link href="http://blog.prashanthellina.com/category/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.prashanthellina.com</link>
	<description>In Pursuit of Truth</description>
	<lastBuildDate>Sun, 28 Nov 2010 09:35:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Even a python can be abused</title>
		<link>http://blog.prashanthellina.com/2008/07/11/even-a-python-can-be-abused/</link>
		<comments>http://blog.prashanthellina.com/2008/07/11/even-a-python-can-be-abused/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 03:16:47 +0000</pubDate>
		<dc:creator>prashanthellina</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[veveo]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[readability]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[visual basic]]></category>

		<guid isPermaLink="false">http://blog.prashanthellina.com/?p=67</guid>
		<description><![CDATA[The first programming language I coded in is QuickBasic. I loved the simplicity and especially the IDE. It made things simple for a starter. Later I discovered Visual Basic which extended the same simplicity and added the &#8220;Visual&#8221; element with a splendid editor for GUI. In between I did some projects using Java, C#, C, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.prashanthellina.com/images/python_abuse.jpg" alt="python abuse" align="left"/>The first programming language I coded in is <strong>QuickBasic</strong>. I loved the simplicity and especially the IDE. It made things simple for a starter. Later I discovered <strong>Visual Basic</strong> which extended the same simplicity and added the &#8220;Visual&#8221; element with a splendid editor for GUI.</p>
<p>In between I did some projects using Java, C#, C, C++. None of these impressed me too much. I hated Java&#8217;s imposition of stiff rules and it&#8217;s dogged adherence to &#8220;everything in a class&#8221; attitude. C# was better. C++ just turned me off because of the monster it is. I did not like C at all because of its total lack of automated memory handling (like GC). I&#8217;ve been doing a lot of coding in C now-a-days as part of my job and I must admit that I like it a lot for its simplicity in primitives and promise of &#8220;closeness to hardware&#8221; and hence the predictability and performance.</p>
<p>I did a small part of my final year project using Python. However, for some unfathomable reason, Python did not impress me at all then. When I started working at Veveo I used Python for a project and got hooked. It&#8217;s simplicity and &#8220;readability&#8221; got me. The power of wielding this tool got me drunk <img src='http://blog.prashanthellina.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Python was designed from the beginning to be a &#8220;easy to read&#8221; language. Most, if not all, of the syntax is intuitive. The indentation adds to the readability aspect. The policy of &#8220;only one way to do a thing&#8221; does wonders for readability. Everyone does a certain thing only the &#8220;one&#8221; way. If you are wondering why the heck I am talking so much about readability, you should consider the fact that an average programmer spends <strong>most</strong> of his time &#8220;reading&#8221; code. You have to read your code after you&#8217;ve just written it. You&#8217;ve to read your code the next day when you resume work. You&#8217;ve to read your code the moment a bug is found. You have to read your code when someone asks you how some aspect of it works a couple of months later. You&#8217;ve have to read your code when making a teeny-weeny feature addition. I just cannot emphasize enough how much time is spent is just reading. There have been times when I would spend a whole day just reading code and finally making &#8220;a single line of code change&#8221; at the end of the day!</p>
<p>So there it is. Python makes it possible to write readable code and that does wonders to programmer productivity. Maintaining your code becomes easier. Understanding your collegues code becomes easier and most of all understanding code written by someone across the world becomes easier &#8211; so you can start reusing components more quickly and with more confidence than ever before.</p>
<p><strong><big>I simply love Python.</big></strong></p>
<p>You must be wondering where I am taking this discussion&#8230; because the title says something about a Python being abused. Who is abusing the Python anyway?</p>
<p>I&#8217;ve noticed how newbies code in Python and found it particulary intriguing. What is interesting here is that every person comes from a certain programming background and are used to doing things in a certain way. When they are thrown into a situation where they have to learn a new language and write some code in it, they invariably apply the vast experience they have in their language of choice <img src='http://blog.prashanthellina.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;ve had the oppurtunity of observing people from Java, C, Perl, VB (yes, Perl) backgrounds writing code in Python. The Java guys stress test multiple inhertitance in Python and bring the much cherished &#8220;everything in a class&#8221; practice to the Python. The C guys who are more often than not obsessed with performace and optimization put their brains to work and implement a strcpy using a &#8220;for loop&#8221; and insist on doing a &#8220;shift&#8221; instead of &#8220;division/multiplication&#8221;. The Perl guys just don&#8217;t seem to like the alphanumerals. They craft Python code with ingenious application making it look very concise. The more characters in one line the better the code. The more non-alphanumerals the better coder you are. That&#8217;s the way of the &#8220;Perl&#8217;ies&#8221;. The VB guys languish for a while complaining constantly about the lack of a proper IDE and after trying out various Python editors, decide to call it quits and go home to comfortable VB. I know, I know &#8230;.. I was a VB guy too and I did search for IDE&#8217;s too &#8230; But then I found VIM and everything was good <img src='http://blog.prashanthellina.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;ve had the good (snigger) fortune of maintaining some of these brilliant artifacts and had my share of nightmares and laugh-outs. I thought I had seen it all, until I saw something today. I told myself &#8212; &#8220;Never underestimate a brilliant C programmer who has found exec and eval in Python&#8221; &#8230; Yes, you can quote me on this <img src='http://blog.prashanthellina.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre lang="Python">
    guido = "is speechless"
    larry = "went nuts"
    sergey = "has seen it all now"
    ...
    ...
    for idx in ['guido','larry','sergey']:
        idxv=eval(idx)
        if(not idxv and dd.has_key(idx)):
            idxv='%s="%s"' %(idx,dd[idx])
            exec(idxv)

    ...
    ...
</pre>
<p><br/><br />
<strong>No&#8230;.. I don&#8217;t think I&#8217;ve seen it all&#8230;. <img src='http://blog.prashanthellina.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.prashanthellina.com/2008/07/11/even-a-python-can-be-abused/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Visualizing mpeg4 motion compensation vectors using mplayer</title>
		<link>http://blog.prashanthellina.com/2008/03/30/visualizing-mpeg4-motion-compensation-vectors-using-mplayer/</link>
		<comments>http://blog.prashanthellina.com/2008/03/30/visualizing-mpeg4-motion-compensation-vectors-using-mplayer/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 18:59:30 +0000</pubDate>
		<dc:creator>prashanthellina</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[motion compensation]]></category>
		<category><![CDATA[mpeg4]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[video compression]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://blog.prashanthellina.com/2008/03/30/visualizing-mpeg4-motion-compensation-vectors-using-mplayer/</guid>
		<description><![CDATA[The MPEG4 video encoding process makes use of block motion compensation to achieve compression. The motion compensation process serves to produce the intra frames which are the frames between keyframes. I&#8217;ve always been fascinated by this process and was delighted to find out that my favorite video player, mplayer, allows one to visualize this process. [...]]]></description>
			<content:encoded><![CDATA[<p>The MPEG4 video encoding process makes use of <strong>block motion compensation</strong> to achieve compression. The motion compensation process serves to produce the intra frames which are the frames between keyframes. I&#8217;ve always been fascinated by this process and was delighted to find out that my favorite video player, <strong>mplayer</strong>, allows one to visualize this process. I tried it and it is wonderful!</p>
<p>This is the video I tried the process on: <a href="http://www.prashanthellina.com/images/motion_vector_video.avi"><strong>download</strong></a></p>
<hr/>
<p><img src="http://www.prashanthellina.com/images/motion_vector_a_0.jpg" alt="motion compensation vector visualization"/><br />
<img src="http://www.prashanthellina.com/images/motion_vector_a_1.jpg" alt="motion compensation vector visualization"/></p>
<hr/>
<p><img src="http://www.prashanthellina.com/images/motion_vector_b_0.jpg" alt="motion compensation vector visualization"/><br />
<img src="http://www.prashanthellina.com/images/motion_vector_b_1.jpg" alt="motion compensation vector visualization"/></p>
<hr/>
<p><img src="http://www.prashanthellina.com/images/motion_vector_c_0.jpg" alt="motion compensation vector visualization"/><br />
<img src="http://www.prashanthellina.com/images/motion_vector_c_1.jpg" alt="motion compensation vector visualization"/></p>
<hr/>
<p><img src="http://www.prashanthellina.com/images/motion_vector_d_0.jpg" alt="motion compensation vector visualization"/></p>
<hr/>
<p>To try this out yourself, you will first need to have <a href="http://www.mplayerhq.hu/design7/news.html">mplayer</a> installed. If you are running Debian/Ubuntu, do this,</p>
<pre lang="bash">
sudo apt-get install mplayer
</pre>
<p><br/><br/></p>
<p>After this, download the video using the link provided above. Run this command,</p>
<pre lang="bash">
mplayer -lavdopts vismv=1 -vo x11 motion_vector_video.avi
</pre>
<p><br/><br/></p>
<p>To learn more about <strong>motion compensation</strong>, go <a href="http://en.wikipedia.org/wiki/Motion_compensation"><strong>here</strong>.</a><br />
<strong><big>Enjoy!</big></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.prashanthellina.com/2008/03/30/visualizing-mpeg4-motion-compensation-vectors-using-mplayer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://www.prashanthellina.com/images/motion_vector_video.avi" length="1780148" type="video/x-msvideo" />
		</item>
		<item>
		<title>Creating video thumbnails using ffmpeg</title>
		<link>http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/</link>
		<comments>http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 19:10:13 +0000</pubDate>
		<dc:creator>prashanthellina</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/</guid>
		<description><![CDATA[Generating thumbnails/screenshots of a video is useful in many ways. Youtube and many other video sites use this to show a preview of the video as a small thumbnail. Google video captures a series of thumbnails from a video at various time intervals to show a better video preview. There is a simple way to [...]]]></description>
			<content:encoded><![CDATA[<p>Generating thumbnails/screenshots of a video is useful in many ways. Youtube and many other video sites use this to show a preview of the video as a small thumbnail. Google video captures a series of thumbnails from a video at various time intervals to show a better video preview.</p>
<p>There is a simple way to generate thumbnails in Linux using ffmpeg, a very very useful tool for processing videos. Let us generate a thumbnail for this <a href="http://www.prashanthellina.com/images/motion_vector_video.avi">video</a>. Download the video and rename it to test.avi.</p>
<p>Then, run this command,</p>
<pre lang="bash">
ffmpeg  -itsoffset -4  -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
</pre>
<p><br/><br/></p>
<p>This command generates a 320&#215;240 sized PNG thumbnail at the 4th second in the video. The output looks like this.<br />
<img src="http://www.prashanthellina.com/images/vid_thumb.jpg" alt="video thumbnail"/></p>
<p>If you do not have ffmpeg installed and are using Debian/Ubuntu, do,</p>
<pre lang="bash">
sudo apt-get install ffmpeg
</pre>
<p><br/><br/></p>
<p>A series of thumbnails, at 4, 8, 12 and 16 seconds.<br />
<img src="http://www.prashanthellina.com/images/vid_thumb.jpg" alt="video thumbnail"/><br />
<img src="http://www.prashanthellina.com/images/vid_thumb_8.jpg" alt="video thumbnail"/><br />
<img src="http://www.prashanthellina.com/images/vid_thumb_12.jpg" alt="video thumbnail"/><br />
<img src="http://www.prashanthellina.com/images/vid_thumb_16.jpg" alt="video thumbnail"/></p>
<pre lang="bash">
ffmpeg  -itsoffset -4  -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg  -itsoffset -8  -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg  -itsoffset -12  -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg  -itsoffset -16  -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
</pre>
<p><br/><br/></p>
<h3>useful links</h3>
<ul>
<li> <a href="http://blog.amnuts.com/2007/06/22/create-a-random-thumbnail-of-a-video-file/">Create a random thumbnail of a video file</a>
<li> <a href="http://www.danielfischer.com/2007/06/27/how-to-use-ffmpeg-to-convert-video-via-ruby-on-rails/">http://www.danielfischer.com/2007/06/27/how-to-use-ffmpeg-to-convert-video-via-ruby-on-rails/</a>
</ul>
<p>Happy thumbnailing!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
<enclosure url="http://www.prashanthellina.com/images/motion_vector_video.avi" length="1780148" type="video/x-msvideo" />
		</item>
		<item>
		<title>Create PDF thumbnails using ImageMagick on Linux</title>
		<link>http://blog.prashanthellina.com/2008/02/03/create-pdf-thumbnails-using-imagemagick-on-linux/</link>
		<comments>http://blog.prashanthellina.com/2008/02/03/create-pdf-thumbnails-using-imagemagick-on-linux/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 08:41:19 +0000</pubDate>
		<dc:creator>prashanthellina</dc:creator>
				<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[thumbnails]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.prashanthellina.com/2008/02/03/create-pdf-thumbnails-using-imagemagick-on-linux/</guid>
		<description><![CDATA[I have a bunch of PDF files for which I wanted to generate thumbnails. On looking around a bit, I found &#8220;ImageMagick&#8220;. Since I have Ubuntu installed, I did sudo apt-get install imagemagick It is not too big a download at around 740KB. To create a thumbnails for all pages in the PDF document (say [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.prashanthellina.com/images/imagemagick_logo.jpg" alt="imagemagick logo" align="right"/>I have a bunch of PDF files for which I wanted to generate thumbnails. On looking around a bit, I found &#8220;<a href="http://www.imagemagick.org">ImageMagick</a>&#8220;. Since I have Ubuntu installed, I did</p>
<pre lang="BASH">
sudo apt-get install imagemagick
</pre>
<p>It is not too big a download at around 740KB.</p>
<p>To create a thumbnails for all pages in the PDF document (say test.pdf which has 3 pages), do</p>
<pre lang="BASH">
convert -thumbnail x300 test.pdf test.png
ls
> test.pdf test-0.png test-1.png test-2.png
</pre>
<p>The &#8220;x300&#8243; tells the &#8220;convert&#8221; tool to keep the height at 300 pixels and modify the width to suit the height. If you have absolute dimensions in mind (say 400&#215;300), do</p>
<pre lang="BASH">
convert -thumbnail 400x300 test.pdf test.png
</pre>
<p>If you want to control the width and have the height suited, do</p>
<pre lang="BASH">
convert -thumbnail 400 test.pdf test.png
</pre>
<p>What do you do if you want only the first page&#8217;s thumbnail? do,</p>
<pre lang="BASH">
convert -thumbnail x300 test.pdf[0] test.png
</pre>
<p>A neat feature of the &#8220;convert&#8221; tool is creation of animated gif&#8217;s having all the pages from the PDF document. do,</p>
<pre lang="BASH">
convert -thumbnail x300 test.pdf test.gif
</pre>
<p>&#8220;convert&#8221; is smart enough to figure out the output format from the file extension you provide in the arguments.</p>
<p>Nifty tools like &#8220;convert&#8221; from the ImageMagick suite are one of the reasons I love Linux! (ImageMagick is cross-platform, I&#8217;m referring the to utility of command-line tools and the UNIX philosophy of specialized tools that do one task really well)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.prashanthellina.com/2008/02/03/create-pdf-thumbnails-using-imagemagick-on-linux/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

