<?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>TikiRobot! &#187; jhead</title>
	<atom:link href="http://www.tikirobot.net/wp/tag/jhead/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tikirobot.net/wp</link>
	<description>Mai Tais and Blinky Lights, Ahoy!</description>
	<lastBuildDate>Wed, 08 Sep 2010 22:09:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Timelapse: OSS Secrets</title>
		<link>http://www.tikirobot.net/wp/2007/11/17/timelapse-oss-secrets/</link>
		<comments>http://www.tikirobot.net/wp/2007/11/17/timelapse-oss-secrets/#comments</comments>
		<pubDate>Sat, 17 Nov 2007 18:40:46 +0000</pubDate>
		<dc:creator>peliom</dc:creator>
				<category><![CDATA[photos]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[timelapse]]></category>

		<guid isPermaLink="false">http://www.tikirobot.net/wp/2007/11/17/timelapse-oss-secrets/</guid>
		<description><![CDATA[I thought I would share a couple of helpful GPL command lines that really get the job done if you want to animate a sequence of images.

First (via Mike) is news of the jhead project.  Unbelievably the ImageCapture.app application that ships with Mac OS X cannot handle more than several thousand images.  ImageCapture.app [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would share a couple of helpful GPL command lines that really get the job done if you want to animate a sequence of images.</p>
<p>
First (via Mike) is news of the <a href="http://www.sentex.net/~mwandel/jhead/">jhead</a> project.  Unbelievably the ImageCapture.app application that ships with Mac OS X cannot handle more than several thousand images.  ImageCapture.app will copy all of the image files, but the number sequence wraps around and it overwrites thousands of the earlier images in the sequence!!  <a href="http://www.sentex.net/~mwandel/jhead/">jhead</a> fixes all that by renaming all of the image files based on the EXIF timestamp in the JPG file.  brilliant!  Here is the commandline he recommends:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">jhead -nfpx<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d-<span style="color: #000000; font-weight: bold;">%</span>H<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #000000; font-weight: bold;">%</span>S <span style="color: #660033;">-dt</span> <span style="color: #660033;">-ft</span> <span style="color: #007800;">$*</span></pre></div></div>

<p>
Now you have a nifty sequence of hopefully hi-res images.  One of the cool things about timelapse is you can shoot 5 megapixel images and then scale them down to NTSC (720&#215;480) or HD (1920&#215;1024) resolution.  In fact if some crazy 5 megapixel video format comes out 10 years from now, you will be able to support that as well! (As an aside, the <a href="http://www.dolby.com/professional/motion_picture/solutions_digitalcinemas.html">Digital Cinema</a> releases that are dribbling out to theaters these days are at 2,000 pixels wide.  Eventually that will go up to 4,000 pixels wide, but there are not currently projectors that can support that resolution!)</p>
<p>
So anyway, megapixels.  How do you scale the images without fudging it up?  A little known fact is that most video that looks crappy because of &#8220;the video compression&#8221; actually looks crappy because of the way the video was scaled down to its postage stamp resolution.  So here is what you do: Use the fantastic <a href="http://www.imagemagick.org/">ImageMagick</a> &#8220;convert&#8221; command to scale your images down at even higher quality than photoshop! for free! and without using a dumb GUI scripting language.  You can read about image scaling in <a href="http://www.xs4all.nl/~bvdwolf/main/foto/down_sample/down_sample.htm">laborious detail</a> or you can just use this command line:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">convert  <span style="color: #660033;">-filter</span> sinc <span style="color: #660033;">-resize</span> 720x480 foo.JPG foo_ntsc.JPG</pre></div></div>

<p>
I put the following bash script into a makefile to process my timelapse library:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>; <span style="color: #000000; font-weight: bold;">do</span>  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>/ntsc_jpg/&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>  <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>/ntsc_jpg&quot;</span>; <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> orig_jpg<span style="color: #000000; font-weight: bold;">/*</span>.JPG; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span>; <span style="color: #7a0874; font-weight: bold;">echo</span> convert  <span style="color: #660033;">-filter</span> sinc <span style="color: #660033;">-resize</span> 720x480 ntsc_jpg<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$i</span><span style="color: #000000; font-weight: bold;">`</span>;  <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">fi</span> <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>And finally I would like to share the &#8220;ghetto HD&#8221; format that VJ Science came up with for doing 16:9 format on an XGA projector.  This command includes cropping to get my 1600&#215;1200 images into 16:9 aspect ratio &#8230; if you have a different source resolution, I&#8217;m going to leave it to you multiply your image width by 9 and divide by 16 to figure out the how many pixels to crop on top and bottom.  The idea is to crop first and then scale down.  Although I guess in terms of quality it doesn&#8217;t matter the order.</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">convert  <span style="color: #660033;">-crop</span> 1600x900+<span style="color: #000000;">0</span>+<span style="color: #000000;">150</span> <span style="color: #660033;">-filter</span> sinc <span style="color: #660033;">-resize</span> 1024x576 foo.JPG foo_xga.JPG</pre></div></div>

<p>
Now you&#8217;ve got a nifty sequence of beautifully scaled images.  Time to make video!  Which of the <a href="http://www.fourcc.org/codecs.php">7 bajillion </a> video codecs are you going to use?  My recommendation is to use <a href="http://ffmpeg.mplayerhq.hu/">ffmpeg</a> to make an mpeg-2 &#8220;master&#8221; that you can distribute by uploading to youtube, archive.org, and so on.  ffmpeg understands image sequences! So here is a quick way to get your mpeg-2 video (no audio).  This command assumes your images are named like &#8220;IMG_0001.JPG&#8221; and so on &#8230; I know that doesn&#8217;t jive with the <a href="http://www.sentex.net/~mwandel/jhead/">jhead</a> naming I&#8217;ve outlined above, but you are a <a href="http://blackhole.sk/big-unix-haxor">big unix haxor</a> and can figure that out.</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ffmpeg</span>  <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;IMG_%04d.JPG&quot;</span> <span style="color: #660033;">-b</span> <span style="color: #000000;">10000</span> test.m2v</pre></div></div>

<p>
For my purpose I am building up a video library for doing VJ/video mixing stuff.  In this use case video quality and decode speed is much more important than bitrate.  Since decoding mpeg-2 &#8220;I&#8221; frames is about 3x faster than decoding &#8220;P&#8221; or &#8220;B&#8221; (difference) frames I use this command to get a high quality I-frame only mpeg-2 stream:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ffmpeg</span>  <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;IMG_%04d.JPG&quot;</span> <span style="color: #660033;">-vcodec</span> mpeg2video <span style="color: #660033;">-intra</span> <span style="color: #660033;">-qscale</span> <span style="color: #000000;">4</span> test.m2v</pre></div></div>

<p>
You can get higher quality by dropping qscale down even lower, but I think if you do qscale=1 your video basically won&#8217;t be compressed at all :-)  rajbot?</p>
<p>
So there you have it! The basics of an Open Source timelapse production pipeline.  I use these tools on <a href="http://finkproject.org/">Mac OS X</a>.  Of course they are available on <a href="http://www.gnu.org/gnu/linux-and-gnu.html">GNU/Linux</a>.  And you can also get them working under windows using <a href="http://www.cygwin.com/">Cygwin</a> &#8230; We need more timelapse!</p>
<p>
<a href="http://www.sentex.net/~mwandel/jhead/">Link</a> to jhead project<br />
<a href="http://www.imagemagick.org/">Link</a> to ImageMagick project<br />
<a href="http://ffmpeg.mplayerhq.hu/">Link</a> to FFmpeg project</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tikirobot.net/wp/2007/11/17/timelapse-oss-secrets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
