<?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/"
	>

<channel>
	<title>David Heidelberger's Blugh</title>
	<atom:link href="http://www.davidheidelberger.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.davidheidelberger.com/blog</link>
	<description>As in, "Ugh, there's a blog?"</description>
	<pubDate>Sun, 08 Aug 2010 20:34:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Drop Frame Timecode [UPDATED]</title>
		<link>http://www.davidheidelberger.com/blog/?p=29</link>
		<comments>http://www.davidheidelberger.com/blog/?p=29#comments</comments>
		<pubDate>Fri, 11 Jun 2010 01:16:18 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.davidheidelberger.com/blog/?p=29</guid>
		<description><![CDATA[In a few moments in this post, I&#8217;m going to include some pseudocode for converting between drop frame timecode and a frame number and vice versa, regardless of framerate. You can skip to that if you want. Or, stay tuned for a little bit of background info. Either way, click through the jump&#8230;
I&#8217;ve been working ]]></description>
			<content:encoded><![CDATA[<div>In a few moments in this post, I&#8217;m going to include some <a href="http://en.wikipedia.org/wiki/Pseudocode">pseudocode</a> for converting between drop frame timecode and a frame number and vice versa, regardless of framerate. You can skip to that if you want. Or, stay tuned for a little bit of background info. Either way, click through the jump&#8230;<span id="more-29"></span></p>
<p>I&#8217;ve been working on a program recently that will hopefully be posted soon that deals with timecode and Quicktime movies. Specifically, adding timecode tracks and doing timecode addition and subtraction. In order to do this, you need to convert the timecode, which is in an hours:minutes:seconds:frames format into a number representing the total number of frames, do your math with frame numbers, and convert back to the timecode format. For non-drop frame timecode, this is trivial. It gets complicated when you&#8217;re dealing with drop frame timecode. If you don&#8217;t know what that is, it&#8217;s a way of accurately measuring the running time of video that doesn&#8217;t run at an even frame rate. In America, video runs at 29.97 frames per second, but we usually count it at 30 fps. This means after a while, the number we use to count is wrong. The solution to this problem is drop frame timecode, which is sort of like leap year for timecode. At 29.97 fps, every minute (except ones divisible by ten), you skip counting the first two frames.?You know you&#8217;re looking at drop frame timecode because the colon between minutes and frames is usually replaced by a semicolon. For example,?you go:</p>
<p>12:38:59;27<br />
12:38:59;27<br />
12:38:59;28<br />
12:38:59;29<br />
and then you skip to&#8230;<br />
12:39:00;02<br />
12:39:00;03</p></div>
<div>It&#8217;s pretty difficult to calculate all of this if you&#8217;re given a frame number, or to calculate a frame number if you&#8217;re given this. After a lot of searching, I&#8217;ve only been able to come up with one website that sets out a formula for how to calculate this, <a href="http://www.andrewduncan.ws/Timecodes/Timecodes.html">Andrew Duncan&#8217;s excellent timecode page</a>. The code I&#8217;m about to post is more or less borrowed straight from that site (with Andrew&#8217;s permission). I&#8217;m really making only two changes. First, I&#8217;m expanding a couple steps to make it a little more like a computer program, and second, I&#8217;m generalizing it so it can calculate drop frame timecode regardless of the frame rate. Andrew&#8217;s site does 29.97 drop frame only, but?you can also have drop frame timecode for 59.94 and even 23.976 (although I don&#8217;t believe it&#8217;s part of the SMPTE spec and I know Final Cut doesn&#8217;t support 24p DF). For 59.94DF, you drop the first four frames per minute. And with 23.976, you drop the first two like in 29.97. So, what I&#8217;m presenting here are basically Andrew&#8217;s formulas, fleshed out a little bit, and generalized to other frame rates. It&#8217;s worth mentioning also that <a href="http://support.apple.com/kb/TS2331">Quicktime has a bug</a> when it comes to dealing with 59.94 DF timecode. In my next post, I&#8217;ll explain how to work around that bug. So, without further ado, here&#8217;s some pseudocode in a vaguely Java style. First, we&#8217;ll convert a frame number into hours, minutes, seconds, and frames [This code has been updated on 8/8/2010 to correct a bug on line 27 caught by Jean-Baptiste Mardelle of <a href="http://kdenlive.org/">Kdenlive</a>]:</div>
<div>
<p>&nbsp;</p>
</div>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">//CONVERT A FRAME NUMBER TO DROP FRAME TIMECODE</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//Code by David Heidelberger, adapted from Andrew Duncan</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//Given an int called framenumber and a double called framerate</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//Framerate should be 29.97, 59.94, or 23.976, otherwise the calculations will be off.</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> d;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> m;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> dropFrames = round<span class="br0">&#40;</span>framerate * .<span class="nu0">066666</span><span class="br0">&#41;</span>; <span class="co1">//Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw4">int</span> framesPerHour = round<span class="br0">&#40;</span>framerate*<span class="nu0">60</span>*<span class="nu0">60</span><span class="br0">&#41;</span>; <span class="co1">//Number of frames in an hour</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> framesPer24Hours = framesPerHour*<span class="nu0">24</span>; <span class="co1">//Number of frames in a day - timecode rolls over after 24 hours</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> framesPer10Minutes = round<span class="br0">&#40;</span>framerate * <span class="nu0">60</span> * <span class="nu0">10</span><span class="br0">&#41;</span>; <span class="co1">//Number of frames per ten minutes</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> framesPerMinute = round<span class="br0">&#40;</span>framerate<span class="br0">&#41;</span>*<span class="nu0">60</span><span class="br0">&#41;</span>- &nbsp;dropFrames; <span class="co1">//Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">if</span> <span class="br0">&#40;</span>framenumber&lt;<span class="nu0">0</span><span class="br0">&#41;</span> <span class="co1">//Negative time. Add 24 hours.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; framenumber=framesPer24Hours+framenumber;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">//If framenumber is greater than 24 hrs, next operation will rollover clock</span></div>
</li>
<li class="li1">
<div class="de1">framenumber = framenumber % framesPer24Hours; <span class="co1">//% is the modulus operator, which returns a remainder. a % b = the remainder of a/b</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">d = framenumber\framesPer10Minutes; <span class="co1">// \ means integer division, which is a/b without a remainder. Some languages you could use floor(a/b)</span></div>
</li>
<li class="li1">
<div class="de1">m = framenumber % framesPer10Minutes</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//In the original post, the next line read m&gt;1, which only worked for 29.97. Jean-Baptiste Mardelle correctly pointed out that m should be compared to dropFrames.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span>m&gt;dropFrames<span class="br0">&#41;</span> </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; framenumber=framenumber + <span class="br0">&#40;</span>dropFrames*<span class="nu0">9</span>*d<span class="br0">&#41;</span> + dropFrames*<span class="br0">&#40;</span><span class="br0">&#40;</span>m-dropFrames<span class="br0">&#41;</span>\framesPerMinute<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">else</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; framenumber = framenumber + dropFrames*<span class="nu0">9</span>*d;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> frRound = round<span class="br0">&#40;</span>framerate<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> frames = framenumber % frRound;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> seconds = <span class="br0">&#40;</span>framenumber \ frRound<span class="br0">&#41;</span> % <span class="nu0">60</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> minutes = <span class="br0">&#40;</span><span class="br0">&#40;</span>framenumber \ frRound<span class="br0">&#41;</span> \ <span class="nu0">60</span><span class="br0">&#41;</span> % <span class="nu0">60</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw4">int</span> hours = <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="br0">&#40;</span>framenumber \ frRound<span class="br0">&#41;</span> \ <span class="nu0">60</span><span class="br0">&#41;</span> \ <span class="nu0">60</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<div>
<p>&nbsp;</p>
</div>
<div>And here&#8217;s the code to convert drop frame timecode to a frame number:</div>
<div>
<p>&nbsp;</p>
</div>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">//CONVERT DROP FRAME TIMECODE TO A FRAME NUMBER</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//Code by David Heidelberger, adapted from Andrew Duncan</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//Given ints called hours, minutes, seconds, frames, and a double called framerate</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw4">int</span> dropFrames = round<span class="br0">&#40;</span>framerate*.<span class="nu0">066666</span><span class="br0">&#41;</span>; <span class="co1">//Number of drop frames is 6% of framerate rounded to nearest integer</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> timeBase = round<span class="br0">&#40;</span>framerate<span class="br0">&#41;</span>; <span class="co1">//We don&#8217;t need the exact framerate anymore, we just need it rounded to nearest integer</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> hourFrames = timeBase*<span class="nu0">60</span>*<span class="nu0">60</span>; <span class="co1">//Number of frames per hour (non-drop)</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> minuteFrames = timebase*<span class="nu0">60</span>; <span class="co1">//Number of frames per minute (non-drop)</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw4">int</span> totalMinutes = <span class="br0">&#40;</span><span class="nu0">60</span>*hours<span class="br0">&#41;</span> + minutes; <span class="co1">//Total number of minuts</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw4">int</span> frameNumber = <span class="br0">&#40;</span><span class="br0">&#40;</span>hourFrames * hours<span class="br0">&#41;</span> + <span class="br0">&#40;</span>minuteFrames * minutes<span class="br0">&#41;</span> + <span class="br0">&#40;</span>timeBase * seconds<span class="br0">&#41;</span> + frames<span class="br0">&#41;</span> - <span class="br0">&#40;</span>dropFrames * <span class="br0">&#40;</span>totalMinutes - <span class="br0">&#40;</span>totalMinutes \ <span class="nu0">10</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">return</span> frameNumber;</div>
</li>
</ol>
</div>
<div>
<p>&nbsp;</p>
</div>
<div>And that&#8217;s it for this entry. In a post to hopefully come in the near future, I&#8217;ll talk about the horrible quicktime 59.94 drop frame bug and how to get around it.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.davidheidelberger.com/blog/?feed=rss2&amp;p=29</wfw:commentRss>
		</item>
		<item>
		<title>New Software Posted - Extension Calculator</title>
		<link>http://www.davidheidelberger.com/blog/?p=21</link>
		<comments>http://www.davidheidelberger.com/blog/?p=21#comments</comments>
		<pubDate>Mon, 11 May 2009 04:48:50 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[16:9]]></category>

		<category><![CDATA[application]]></category>

		<category><![CDATA[aspect ratio]]></category>

		<category><![CDATA[calculator]]></category>

		<category><![CDATA[extension]]></category>

		<category><![CDATA[photo]]></category>

		<category><![CDATA[program]]></category>

		<category><![CDATA[update]]></category>

		<category><![CDATA[widescreen]]></category>

		<guid isPermaLink="false">http://www.davidheidelberger.com/blog/?p=21</guid>
		<description><![CDATA[I just posted a new application I wrote to the software page. It&#8217;s called the Extension Calculator.?There is no reason that anyone would need this program. Usually. I recently had an issue at work where someone was going to extend the edges (by painting in a new background) of some vertical photos so they would ]]></description>
			<content:encoded><![CDATA[<p>I just posted a <a href="http://www.davidheidelberger.com/software/extension.dmg">new application</a> I wrote to the <a href="http://www.davidheidelberger.com/software.php">software page</a>. It&#8217;s called the Extension Calculator.?There is no reason that anyone would need this program. Usually. I recently had an issue at work where someone was going to extend the edges (by painting in a new background) of some vertical photos so they would fit a 16:9 frame.</p>
<p>?</p>
<p><div id="attachment_22" class="wp-caption aligncenter" style="width: 458px"><img class="size-full wp-image-22 " title="frame_issue" src="http://www.davidheidelberger.com/blog/wp-content/uploads/2009/05/frame_issue.jpg" alt="Vertical photo in a 16:9 frame" width="448" height="252" /><p class="wp-caption-text">Vertical photo in a 16:9 frame</p></div></p>
<p>They wanted to know what dimensions they needed to extend it to. Since each photo was a different size, I wrote a program to calculate what size they should be extended to in order to make them 16:9. So, as you can see, it&#8217;s a very niche sort of task, but maybe it&#8217;s useful for someone sometime, who knows. Simply drag an image into the well on the left side of the application and it will display what the new dimensions need to be. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidheidelberger.com/blog/?feed=rss2&amp;p=21</wfw:commentRss>
		</item>
		<item>
		<title>Copyright Cops</title>
		<link>http://www.davidheidelberger.com/blog/?p=18</link>
		<comments>http://www.davidheidelberger.com/blog/?p=18#comments</comments>
		<pubDate>Tue, 07 Apr 2009 23:37:07 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[benjamin]]></category>

		<category><![CDATA[bollywood]]></category>

		<category><![CDATA[button]]></category>

		<category><![CDATA[case]]></category>

		<category><![CDATA[copyright]]></category>

		<category><![CDATA[curious]]></category>

		<category><![CDATA[domain]]></category>

		<category><![CDATA[fair]]></category>

		<category><![CDATA[fitzgerald]]></category>

		<category><![CDATA[nazis]]></category>

		<category><![CDATA[public]]></category>

		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://www.davidheidelberger.com/blog/?p=18</guid>
		<description><![CDATA[This item appeared on the imdb today:
Bollywood Producers Warned Against Button Remake
The Hollywood producers behind The Curious Case Of Benjamin Button are threatening legal action against Bollywood filmmakers over their plans to remake Brad Pitt&#8217;s Oscar-winning movie.
&#8230;
A New Delhi law firm representing Warner Brothers will pursue legal action against any film made ?either in English ]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://www.imdb.com/news/ni0737771/">item</a> appeared on the <a href="http://www.imdb.com">imdb </a>today:</p>
<blockquote><p><strong>Bollywood Producers Warned Against Button Remake</strong></p>
<p>The Hollywood producers behind The Curious Case Of Benjamin Button are threatening legal action against Bollywood filmmakers over their plans to remake Brad Pitt&#8217;s Oscar-winning movie.<br />
&#8230;<br />
A New Delhi law firm representing Warner Brothers will pursue legal action against any film made ?either in English or Hindi or other language, having a similar script, screenplay or story line or character sketches or interplay of characters or sequence of events? to the original movie, reports Agence France-Presse.</p></blockquote>
<p>This is pretty unbelievable. Let&#8217;s look at what Warner Brothers had to pay to secure the Button franchise. If they paid anything more than $0, they got ripped off, because the short story &#8220;The Curious Case of Benjamin Button&#8221; by F. Scott Fitzgerald was published in 1922 and is, therefore, in the public domain. Yes. Warner Brothers wants to sue some Bollywood company over their use of PUBLIC DOMAIN MATERIAL. Granted, WB used the original short story as a jumping-off point for their own film, but honestly, how can they sue for similar &#8220;story-lines&#8221; when they don&#8217;t own the story-line? This sort of thing makes me furious. While I&#8217;m on the subject&#8230;there must be broader and more-clearly defined terms of fair-use in this country and congress should be hastening the entry of material into the public domain, not slowing it. If all public knowledge stops (as it does now, with some exceptions) in 1923, innovation is stifled.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidheidelberger.com/blog/?feed=rss2&amp;p=18</wfw:commentRss>
		</item>
		<item>
		<title>Nice Write-Up</title>
		<link>http://www.davidheidelberger.com/blog/?p=14</link>
		<comments>http://www.davidheidelberger.com/blog/?p=14#comments</comments>
		<pubDate>Tue, 07 Apr 2009 23:19:45 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[brilliant]]></category>

		<category><![CDATA[discoveries]]></category>

		<category><![CDATA[i'm]]></category>

		<category><![CDATA[myfilm]]></category>

		<category><![CDATA[not]]></category>

		<category><![CDATA[two]]></category>

		<category><![CDATA[woody]]></category>

		<guid isPermaLink="false">http://www.davidheidelberger.com/blog/?p=14</guid>
		<description><![CDATA[Two of the films on my site, Two Brilliant Discoveries and I&#8217;m Not Woody, got a nice shout-out from the folks over at myfilm.com. I&#8217;m not sure how they found out about me, but thanks, guys. I will definitely be checking out your blog from now on. And so should you, readers.
]]></description>
			<content:encoded><![CDATA[<p>Two of the films on my site, Two Brilliant Discoveries and I&#8217;m Not Woody, got a nice <a href="http://www.myfilm.com/2009_03_01_archive.html#5545670692602227916">shout-out</a> from the folks over at <a href="http://www.myfilm.com">myfilm.com</a>. I&#8217;m not sure how they found out about me, but thanks, guys. I will definitely be checking out your blog from now on. And so should you, readers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidheidelberger.com/blog/?feed=rss2&amp;p=14</wfw:commentRss>
		</item>
		<item>
		<title>Site Feedback</title>
		<link>http://www.davidheidelberger.com/blog/?p=9</link>
		<comments>http://www.davidheidelberger.com/blog/?p=9#comments</comments>
		<pubDate>Sun, 04 Jan 2009 23:48:29 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Site]]></category>

		<category><![CDATA[Feedback]]></category>

		<guid isPermaLink="false">http://www.davidheidelberger.com/blog/?p=9</guid>
		<description><![CDATA[Please leave any site feedback in the comments section of this post.
]]></description>
			<content:encoded><![CDATA[<p>Please leave any site feedback in the comments section of this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidheidelberger.com/blog/?feed=rss2&amp;p=9</wfw:commentRss>
		</item>
		<item>
		<title>There&#8217;s a Blog</title>
		<link>http://www.davidheidelberger.com/blog/?p=7</link>
		<comments>http://www.davidheidelberger.com/blog/?p=7#comments</comments>
		<pubDate>Sun, 04 Jan 2009 23:47:53 +0000</pubDate>
		<dc:creator>David</dc:creator>
		
		<category><![CDATA[Site]]></category>

		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.davidheidelberger.com/blog/?p=7</guid>
		<description><![CDATA[Yeah, so there&#8217;s a blog. Will I update it? Eh. Maybe. We&#8217;ll see.
]]></description>
			<content:encoded><![CDATA[<p>Yeah, so there&#8217;s a blog. Will I update it? Eh. Maybe. We&#8217;ll see.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidheidelberger.com/blog/?feed=rss2&amp;p=7</wfw:commentRss>
		</item>
	</channel>
</rss>

