<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://commons.oreilly.com/wiki/skins/common/feed.css?97"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>QuickTime for Java: A Developer's Notebook/Video Media - Revision history</title>
		<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.11.0</generator>
		<lastBuildDate>Wed, 19 Jun 2013 00:33:13 GMT</lastBuildDate>
		<item>
			<title>Newacct at 09:26, 14 December 2010</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=26276&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 09:26, 14 December 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 559:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 559:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;       } catch (Exception e) {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;       } catch (Exception e) {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           // make random start rect&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           // make random start rect&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int startX = &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Math.abs (&lt;/del&gt;rand.nextInt( &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;) % &lt;/del&gt;rightStop);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int startX = rand.nextInt (rightStop);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int startY = &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Math.abs (&lt;/del&gt;rand.nextInt( &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;) % &lt;/del&gt;bottomStop);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int startY = rand.nextInt (bottomStop);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           startRect = new QDRect (startX, startY, &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           startRect = new QDRect (startX, startY, &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;                                   VIDEO_TRACK_WIDTH,&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;                                   VIDEO_TRACK_WIDTH,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 577:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 577:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           float zoom = (rand.nextFloat( ) - 0.5f); // -0.5 &amp;lt;= zoom &amp;lt;= 0.5&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           float zoom = (rand.nextFloat( ) - 0.5f); // -0.5 &amp;lt;= zoom &amp;lt;= 0.5&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           System.out.println (&amp;quot;zoom = &amp;quot; + zoom);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           System.out.println (&amp;quot;zoom = &amp;quot; + zoom);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int endX = &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Math.abs (&lt;/del&gt;rand.nextInt( &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;) % &lt;/del&gt;rightStop);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int endX = rand.nextInt (rightStop);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int endY = &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Math.abs (&lt;/del&gt;rand.nextInt( &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;) % &lt;/del&gt;bottomStop);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           int endY = rand.nextInt (bottomStop);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           endRect = new QDRect (endX, endY,&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;           endRect = new QDRect (endX, endY,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;                                 VIDEO_TRACK_WIDTH * zoom,&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;                                 VIDEO_TRACK_WIDTH * zoom,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Tue, 14 Dec 2010 09:26:32 GMT</pubDate>			<dc:creator>Newacct</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Docbook2Wiki: Initial conversion from Docbook</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=7243&amp;oldid=prev</link>
			<description>&lt;p&gt;Initial conversion from Docbook&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 13:22, 7 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;</description>
			<pubDate>Fri, 07 Mar 2008 13:22:47 GMT</pubDate>			<dc:creator>Docbook2Wiki</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Docbook2Wiki: Initial conversion from Docbook</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=7164&amp;oldid=prev</link>
			<description>&lt;p&gt;Initial conversion from Docbook&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 13:17, 7 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 198:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 198:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This mirror effect is pretty handy, and you might use it all by itself for doing something like a capture preview. Because the &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; can be used on movie tracks, &amp;lt;tt&amp;gt;GraphicsImporter&amp;lt;/tt&amp;gt;s, and various other parts of the QuickTime API, mastering &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; transformations will get you &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;'''' &lt;/del&gt;pretty far.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This mirror effect is pretty handy, and you might use it all by itself for doing something like a capture preview. Because the &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; can be used on movie tracks, &amp;lt;tt&amp;gt;GraphicsImporter&amp;lt;/tt&amp;gt;s, and various other parts of the QuickTime API, mastering &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; transformations will get you &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;pretty far.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Fri, 07 Mar 2008 13:17:34 GMT</pubDate>			<dc:creator>Docbook2Wiki</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Evanlenz: 1 revision(s)</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=4469&amp;oldid=prev</link>
			<description>&lt;p&gt;1 revision(s)&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 00:26, 7 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;</description>
			<pubDate>Fri, 07 Mar 2008 00:26:01 GMT</pubDate>			<dc:creator>Evanlenz</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Docbook2Wiki: Initial conversion from Docbook</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=4468&amp;oldid=prev</link>
			<description>&lt;p&gt;Initial conversion from Docbook&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 00:17, 7 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 144:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 144:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-1. Matrix-based transformation of foreground video track'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-1. Matrix-based transformation of foreground video track'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developer's &lt;/del&gt;Notebook_I_8_tt210.png|Matrix-based transformation of foreground video track]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developers &lt;/ins&gt;Notebook_I_8_tt210.png|Matrix-based transformation of foreground video track]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-2. Matrix-based mirror image transformation steps: original, scaled by x-factor of -1, translated by adding width'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-2. Matrix-based mirror image transformation steps: original, scaled by x-factor of -1, translated by adding width'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developer's &lt;/del&gt;Notebook_I_8_tt213.png|Matrix-based mirror image transformation steps: original, scaled by x-factor of -1, translated by adding width]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developers &lt;/ins&gt;Notebook_I_8_tt213.png|Matrix-based mirror image transformation steps: original, scaled by x-factor of -1, translated by adding width]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 195:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 195:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-3. Matrix-based mirror image of foreground video track'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-3. Matrix-based mirror image of foreground video track'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developer's &lt;/del&gt;Notebook_I_8_tt214.png|Matrix-based mirror image of foreground video track]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developers &lt;/ins&gt;Notebook_I_8_tt214.png|Matrix-based mirror image of foreground video track]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 232:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 232:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-4. Composited video tracks with addMax graphics mode'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-4. Composited video tracks with addMax graphics mode'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developer's &lt;/del&gt;Notebook_I_8_tt216.png|Composited video tracks with addMax graphics mode]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developers &lt;/ins&gt;Notebook_I_8_tt216.png|Composited video tracks with addMax graphics mode]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 254:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 254:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-5. Composited video tracks with srcBic graphics mode'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-5. Composited video tracks with srcBic graphics mode'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developer's &lt;/del&gt;Notebook_I_8_tt217.png|Composited video tracks with srcBic graphics mode]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developers &lt;/ins&gt;Notebook_I_8_tt217.png|Composited video tracks with srcBic graphics mode]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 653:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 653:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-6. Movie built via addSample( ) from portions of a static image'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;'''Figure 8-6. Movie built via addSample( ) from portions of a static image'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developer's &lt;/del&gt;Notebook_I_8_tt220.png|Movie built via addSample( ) from portions of a static image]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Image:QuickTime for Java: A &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Developers &lt;/ins&gt;Notebook_I_8_tt220.png|Movie built via addSample( ) from portions of a static image]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Fri, 07 Mar 2008 00:17:35 GMT</pubDate>			<dc:creator>Docbook2Wiki</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Evanlenz: 1 revision(s)</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=4317&amp;oldid=prev</link>
			<description>&lt;p&gt;1 revision(s)&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 00:16, 7 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;</description>
			<pubDate>Fri, 07 Mar 2008 00:16:22 GMT</pubDate>			<dc:creator>Evanlenz</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Docbook2Wiki: Initial conversion from Docbook</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=4316&amp;oldid=prev</link>
			<description>&lt;p&gt;Initial conversion from Docbook&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 00:15, 7 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;</description>
			<pubDate>Fri, 07 Mar 2008 00:15:32 GMT</pubDate>			<dc:creator>Docbook2Wiki</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Evanlenz: 1 revision(s)</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=4165&amp;oldid=prev</link>
			<description>&lt;p&gt;1 revision(s)&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 23:57, 6 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;</description>
			<pubDate>Thu, 06 Mar 2008 23:57:59 GMT</pubDate>			<dc:creator>Evanlenz</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
		<item>
			<title>Docbook2Wiki: Initial conversion from Docbook</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media&amp;diff=4164&amp;oldid=prev</link>
			<description>&lt;p&gt;Initial conversion from Docbook&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{QuickTime for Java: A Developer's Notebook/TOC}}&lt;br /&gt;
It probably seems like half of this book has already been about video—I've assumed you had video media for the chapters on playback, editing, and components ([[QuickTime for Java: A Developer's Notebook/Playing Movies|Chapter 2]] and [[QuickTime for Java: A Developer's Notebook/Working with Components|Chapter 4]]), even though the material there would be perfectly well suited for use on audio-only media like MP3 files. Well, this chapter is ''only'' about video, showing a handful of useful tricks for working with video.&lt;br /&gt;
&lt;br /&gt;
Because video is simply a progression of images, alternated quickly enough to suggest movement, you probably won't be too surprised to know that the material covered in the QuickDraw graphics chapter ([[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]]) pays off in this chapter. QuickDraw and QD-like APIs are the means by which you create and/or manipulate video media. If you skipped that chapter and have problems herein with &amp;lt;tt&amp;gt;QDGraphics&amp;lt;/tt&amp;gt; (a.k.a. &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;s), &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt;es, &amp;lt;tt&amp;gt;GraphicsImporter&amp;lt;/tt&amp;gt;s, or compression, you might need to check back there. But I'll try to keep things fairly self-explanatory.&lt;br /&gt;
&lt;br /&gt;
== Combining Video Tracks ==&lt;br /&gt;
&lt;br /&gt;
It's not hard to understand how two audio tracks can coexist in a movie—the sounds are mixed and played together. But the idea of combining video tracks is less intuitive.&lt;br /&gt;
&lt;br /&gt;
By default, if you have two video tracks of the same size in a movie, one will totally overlap the other. But you can change the default behavior by specifying 2D transformations with &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; objects, and the Z-axis ordering by setting &amp;quot;layering&amp;quot; behavior.&lt;br /&gt;
&lt;br /&gt;
One way to play with &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt;-based spatial arrangement is to set up a ''picture-in-picture'' movie. In such a movie, the foreground video is scaled and moved into a corner relative to the background video.&lt;br /&gt;
&lt;br /&gt;
=== How do I do that? ===&lt;br /&gt;
&lt;br /&gt;
To do a picture-in-picture effect, you must have a movie with two video tracks and you must do three things to the foreground video track:&lt;br /&gt;
&lt;br /&gt;
* Scale it to a size smaller than the background track.&lt;br /&gt;
* Optionally move it to a location other than (0,0).&lt;br /&gt;
* Set layering to ensure it appears above the background track.&lt;br /&gt;
&lt;br /&gt;
Fortunately, a few methods in the &amp;lt;tt&amp;gt;Track&amp;lt;/tt&amp;gt; class provide all of this. The application in [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-EX-1|Example 8-1]] brings up a window with a picture-in-picture effect achieved with matrix transformations and layering.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Run this example from the downloaded book code with ant run-ch08-matrixvideotracks''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-EX-1&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 8-1. Matrix-based video picture-in-picture'''&lt;br /&gt;
&lt;br /&gt;
 package com.oreilly.qtjnotebook.ch08;&lt;br /&gt;
  &lt;br /&gt;
 import quicktime.*;&lt;br /&gt;
 import quicktime.std.*;&lt;br /&gt;
 import quicktime.std.movies.*;&lt;br /&gt;
 import quicktime.std.movies.media.*;&lt;br /&gt;
 import quicktime.std.image.*;&lt;br /&gt;
 import quicktime.io.*;&lt;br /&gt;
 import quicktime.qd.*;&lt;br /&gt;
 import quicktime.util.*;&lt;br /&gt;
 import quicktime.app.view.*;&lt;br /&gt;
  &lt;br /&gt;
 import com.oreilly.qtjnotebook.ch01.QTSessionCheck;&lt;br /&gt;
  &lt;br /&gt;
 import java.awt.*;&lt;br /&gt;
  &lt;br /&gt;
 public class MatrixVideoTracks extends Frame {&lt;br /&gt;
  &lt;br /&gt;
 static Movie foreMovie, backMovie;&lt;br /&gt;
  &lt;br /&gt;
 public static void main(String[  ] args) {&lt;br /&gt;
   try {&lt;br /&gt;
       QTSessionCheck.check( );&lt;br /&gt;
       // get background movie&lt;br /&gt;
       QTFile file = &lt;br /&gt;
           QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);&lt;br /&gt;
       OpenMovieFile omf = OpenMovieFile.asRead(file);&lt;br /&gt;
       backMovie = Movie.fromFile (omf);&lt;br /&gt;
       // get foreground movie&lt;br /&gt;
       file = QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);&lt;br /&gt;
       omf = OpenMovieFile.asRead(file);&lt;br /&gt;
       foreMovie = Movie.fromFile (omf);&lt;br /&gt;
       // get frame&lt;br /&gt;
       Frame frame = new MatrixVideoTracks (backMovie, foreMovie);&lt;br /&gt;
       frame.pack( );&lt;br /&gt;
       frame.setVisible (true);&lt;br /&gt;
   } catch (QTException qte) {&lt;br /&gt;
       qte.printStackTrace( );&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public MatrixVideoTracks (Movie backMovie, Movie foreMovie)&lt;br /&gt;
   throws QTException {&lt;br /&gt;
   super (&amp;quot;Matrix Video Tracks&amp;quot;);&lt;br /&gt;
   Movie matrixMovie = new Movie( );&lt;br /&gt;
   // build tracks&lt;br /&gt;
   Track foreTrack = addVideoTrack (foreMovie, matrixMovie);&lt;br /&gt;
   Track backTrack = addVideoTrack (backMovie, matrixMovie);&lt;br /&gt;
   // set matrix transformation&lt;br /&gt;
   Matrix foreMatrix = new Matrix( );&lt;br /&gt;
   // set matrix to move fore to bottom right 1/4 or back&lt;br /&gt;
   QDRect foreFrom =&lt;br /&gt;
       new QDRect (0, 0,&lt;br /&gt;
                   foreTrack.getSize( ).getWidth( ),&lt;br /&gt;
                   foreTrack.getSize( ).getHeight( ));&lt;br /&gt;
   QDRect foreTo = &lt;br /&gt;
       new QDRect (backTrack.getSize( ).getWidth( ) / 2,&lt;br /&gt;
                   backTrack.getSize( ).getHeight( ) / 2,&lt;br /&gt;
                   backTrack.getSize( ).getWidth( ) / 2,&lt;br /&gt;
                   backTrack.getSize( ).getHeight( ) / 2);&lt;br /&gt;
   System.out.println (&amp;quot;foreTo is = &amp;quot; + foreTo);&lt;br /&gt;
   foreMatrix.rect (foreFrom, foreTo);&lt;br /&gt;
   foreTrack.setMatrix (foreMatrix);&lt;br /&gt;
   // set foreTrack's layer&lt;br /&gt;
   foreTrack.setLayer (-1);&lt;br /&gt;
   // now get component and add to frame&lt;br /&gt;
   MovieController controller = new MovieController(matrixMovie);&lt;br /&gt;
   Component c = QTFactory.makeQTComponent(controller).asComponent( );&lt;br /&gt;
   add (c);&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public Track addVideoTrack (Movie sourceMovie, Movie targetMovie)&lt;br /&gt;
   throws QTException { &lt;br /&gt;
   // find first video track&lt;br /&gt;
   Track videoTrack = &lt;br /&gt;
       sourceMovie.getIndTrackType (1,&lt;br /&gt;
                                    StdQTConstants.videoMediaType,&lt;br /&gt;
                                    StdQTConstants.movieTrackMediaType);&lt;br /&gt;
   if (videoTrack =  = null)&lt;br /&gt;
       throw new QTException (&amp;quot;can't find a video track&amp;quot;);&lt;br /&gt;
   // add videoTrack to targetMovie&lt;br /&gt;
   Track newTrack =&lt;br /&gt;
       targetMovie.newTrack (videoTrack.getSize( ).getWidthF( ),&lt;br /&gt;
                             videoTrack.getSize( ).getHeightF( ),&lt;br /&gt;
                             1.0f);&lt;br /&gt;
   VideoMedia newMedia = &lt;br /&gt;
       new VideoMedia (newTrack,&lt;br /&gt;
                       videoTrack.getMedia( ).getTimeScale( ),&lt;br /&gt;
                       new DataRef(new QTHandle( )));&lt;br /&gt;
   videoTrack.insertSegment (newTrack,&lt;br /&gt;
                            0,&lt;br /&gt;
                            videoTrack.getDuration( ),&lt;br /&gt;
                            0);&lt;br /&gt;
   return newTrack;&lt;br /&gt;
 }&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When this is run, the user is shown two consecutive movie-opening dialogs, for the background and foreground movies, respectively. Assuming that both have video tracks, the result looks like [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-FIG-1|Figure 8-1]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''This example looks for a track with video media, so don't use audio-only files, or MPEG-1, which has a special &amp;quot;MPEG media&amp;quot; track instead of video''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What just happened? ===&lt;br /&gt;
&lt;br /&gt;
After the two movies are loaded, this demo creates a new empty target movie and, through a convenience method called &amp;lt;tt&amp;gt;addVideoTrack( )&amp;lt;/tt&amp;gt; , finds the video tracks of the selected movies, creates new video tracks in the target movie, and inserts the &amp;lt;tt&amp;gt;VideoMedia&amp;lt;/tt&amp;gt; from the source movies. This produces a movie with two concurrent video tracks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-FIG-1&amp;quot;&amp;gt;&lt;br /&gt;
'''Figure 8-1. Matrix-based transformation of foreground video track'''&lt;br /&gt;
&lt;br /&gt;
[[Image:QuickTime for Java: A Developer's Notebook_I_8_tt210.png|Matrix-based transformation of foreground video track]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To scale and move the foreground track, you use a &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; transformation. In this case, the example takes the background movie's video track size and finds its center point, then sets up a destination rectangle with that point as its upper-left corner, with width and height equal to half the foreground's width and height, respectively. Finally, it tells the foreground track to use this matrix by calling &amp;lt;tt&amp;gt;Track.setMatrix()&amp;lt;/tt&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''[[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]] introduced Matrix. It's a mathematical object used in QuickTime to describe 2D transformations like scaling, rotation, etc''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 QDRect foreFrom =&lt;br /&gt;
   new QDRect (0, 0,&lt;br /&gt;
               foreTrack.getSize( ).getWidth( ),&lt;br /&gt;
               foreTrack.getSize( ).getHeight( ));&lt;br /&gt;
 QDRect foreTo = &lt;br /&gt;
   new QDRect (backTrack.getSize( ).getWidth( ) / 2,&lt;br /&gt;
               backTrack.getSize( ).getHeight( ) / 2,&lt;br /&gt;
               backTrack.getSize( ).getWidth( ) / 2,&lt;br /&gt;
               backTrack.getSize( ).getHeight( ) / 2);&lt;br /&gt;
 foreMatrix.rect (foreFrom, foreTo);&lt;br /&gt;
 foreTrack.setMatrix (foreMatrix);&lt;br /&gt;
&lt;br /&gt;
Next, to ensure that the foreground track draws above the background—if it doesn't, all this matrix work will be wasted—the demo calls &amp;lt;tt&amp;gt;Track.setLayer(-1)&amp;lt;/tt&amp;gt; . The layers are numbered from -32,767 to 32,767, with lower-numbered layers appearing above higher-numbered layers. The background track keeps its default layer, 0, so setting the foreground to -1 forces it to be on top.&lt;br /&gt;
&lt;br /&gt;
=== What about... ===&lt;br /&gt;
&lt;br /&gt;
...the point of this? Am I really ever going to want to overlay video tracks? It's more common than you might think. Consider Apple's iChat AV application—it uses a very similar picture-in-picture effect, so you can see yourself when you videoconference with a friend.&lt;br /&gt;
&lt;br /&gt;
But there's one other interesting thing that iChat AV does: it shows the video of you as a ''mirror image'' . This, presumably, is more natural for users—if you raise your right hand, it somehow makes more sense to see your hand go up on the right side of the preview window, even if that's not what the camera is really seeing. Fortunately, a mirror image is really simple to do with a &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; transformation.&lt;br /&gt;
&lt;br /&gt;
In the preceding example, add the following two lines right after the &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; is created:&lt;br /&gt;
&lt;br /&gt;
 foreMatrix.scale (-1, 1, 0, 0);&lt;br /&gt;
 foreMatrix.translate ((float) foreTrack.getSize( ).getWidth( ), 0f );&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;scale( )&amp;lt;/tt&amp;gt; call makes the matrix multiply all pixels by -1, effectively &amp;quot;flipping&amp;quot; them around the x-axis. The y-coordinates are unchanged, so the scaling factor there is 1. The last two arguments define the &amp;quot;anchor point.&amp;quot; By using 0, this says &amp;quot;flip around the x-axis&amp;quot; (the y-coordinate is similar but irrelevant here). Given an image width of ''w'', this scaling operation makes the pixels run from ''-w'' to 0. The &amp;lt;tt&amp;gt;translate( )&amp;lt;/tt&amp;gt; call moves the coordinates back into positive coordinate space. [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-FIG-2|Figure 8-2]] shows this transformation conceptually.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-FIG-2&amp;quot;&amp;gt;&lt;br /&gt;
'''Figure 8-2. Matrix-based mirror image transformation steps: original, scaled by x-factor of -1, translated by adding width'''&lt;br /&gt;
&lt;br /&gt;
[[Image:QuickTime for Java: A Developer's Notebook_I_8_tt213.png|Matrix-based mirror image transformation steps: original, scaled by x-factor of -1, translated by adding width]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For this to work you also need to change the &amp;lt;tt&amp;gt;Matrix.rect()&amp;lt;/tt&amp;gt; call to &amp;lt;tt&amp;gt;Matrix.map( )&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;rect( )&amp;lt;/tt&amp;gt; clears out any previous transformations, essentially defining a new matrix that represents only the translate-and-scale from one rectangle to another, while &amp;lt;tt&amp;gt;map( )&amp;lt;/tt&amp;gt; maintains the previous transformations and ''then'' applies the translate-and-scale.&lt;br /&gt;
&lt;br /&gt;
[[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-FIG-3|Figure 8-3]] shows the demo running with this mirror image added to the foreground transformation. For this figure, I've used the same video source for foreground and background, to make the mirror transformation more obvious.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-FIG-3&amp;quot;&amp;gt;&lt;br /&gt;
'''Figure 8-3. Matrix-based mirror image of foreground video track'''&lt;br /&gt;
&lt;br /&gt;
[[Image:QuickTime for Java: A Developer's Notebook_I_8_tt214.png|Matrix-based mirror image of foreground video track]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This mirror effect is pretty handy, and you might use it all by itself for doing something like a capture preview. Because the &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; can be used on movie tracks, &amp;lt;tt&amp;gt;GraphicsImporter&amp;lt;/tt&amp;gt;s, and various other parts of the QuickTime API, mastering &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; transformations will get you '''' pretty far.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Did you notice the capture settings dialog in [[QuickTime for Java: A Developer's Notebook/Capture|Chapter 6]] showed a mirror image? You could use a Matrix to make the motion detector in that chapter render a mirror image, too''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overlaying Video Tracks ==&lt;br /&gt;
&lt;br /&gt;
When one video track is drawn on top of another, the top doesn't necessarily have to obscure the bottom. QuickTime gives you the option of specifying a &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; to combine pixels from multiple video layers to create interesting effects.&lt;br /&gt;
&lt;br /&gt;
=== How do I do that? ===&lt;br /&gt;
&lt;br /&gt;
You can create a &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; object to describe the means of combining overlapping colors. To try it out, take the previous lab's code and replace all the matrix stuff (after the &amp;lt;tt&amp;gt;foreTrack&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;backTrack&amp;lt;/tt&amp;gt; are created, but before the &amp;lt;tt&amp;gt;MovieController&amp;lt;/tt&amp;gt; is created) with the following:&lt;br /&gt;
&lt;br /&gt;
 GraphicsMode gm = new GraphicsMode (QDConstants.addMax,&lt;br /&gt;
                                   QDColor.green);&lt;br /&gt;
 VisualMediaHandler foreHandler = &lt;br /&gt;
   (VisualMediaHandler) foreTrack.getMedia( ).getHandler( );&lt;br /&gt;
 foreHandler.setGraphicsMode(gm);&lt;br /&gt;
 foreTrack.setLayer(-1);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Run this example with ant run-ch08-composit-evideotracks''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When run, this sample program asks you to open two movies, then creates a new movie with video tracks from the source movies' media, and combines the pixels of the foreground movie with the background, so the foreground appears atop the background. The result is shown in [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-FIG-4|Figure 8-4]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-FIG-4&amp;quot;&amp;gt;&lt;br /&gt;
'''Figure 8-4. Composited video tracks with addMax graphics mode'''&lt;br /&gt;
&lt;br /&gt;
[[Image:QuickTime for Java: A Developer's Notebook_I_8_tt216.png|Composited video tracks with addMax graphics mode]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What just happened? ===&lt;br /&gt;
&lt;br /&gt;
Setting a &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; instructs QuickTime to apply a specific behavior to combine overlapping pixels. The &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; has a &amp;quot;mode&amp;quot; &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;, which indicates which kind of behavior to use, and a &amp;lt;tt&amp;gt;QDColor&amp;lt;/tt&amp;gt; that is used by some behaviors to indicate a color to operate on. For example, you might use mode &amp;lt;tt&amp;gt;QDConstants.transparent&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;QDColor.green&amp;lt;/tt&amp;gt; to make all green pixels transparent. The default mode is &amp;lt;tt&amp;gt;srcCopy&amp;lt;/tt&amp;gt;, which simply copies one set of pixels on top of another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''[[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]] showed how to set up GraphicsMode compositing of still images. Video works in pretty much the same way''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To apply this &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; to overlapping video tracks, you call &amp;lt;tt&amp;gt;setGraphicsMode( )&amp;lt;/tt&amp;gt; , a method not defined by &amp;lt;tt&amp;gt;Track&amp;lt;/tt&amp;gt; but, rather, by the &amp;lt;tt&amp;gt;VideoMediaHandler&amp;lt;/tt&amp;gt;. As a reminder, movies have tracks, tracks have media, and media have handlers. Actually, the &amp;lt;tt&amp;gt;setGraphicsMode()&amp;lt;/tt&amp;gt; is defined by the &amp;lt;tt&amp;gt;VisualMediaHandler&amp;lt;/tt&amp;gt; interface, making it available for all visual media (&amp;lt;tt&amp;gt;MPEGMedia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;TextMedia&amp;lt;/tt&amp;gt;, etc.).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;addMax&amp;lt;/tt&amp;gt; behavior combines background and foreground pixels, using the maximum red, green, and blue values of each. This has the effect of producing something of a washed-out combination of the two video tracks, because bright colors in either source will be copied over to the screen.&lt;br /&gt;
&lt;br /&gt;
The available &amp;lt;tt&amp;gt;QDConstant&amp;lt;/tt&amp;gt; modes offer several dozen behaviors—check them out in the QuickTime documentation by searching Apple's site for &amp;quot;Graphics Transfer Modes&amp;quot;—though some of them aren't suitable for color images, and many of them produce garish results with real-world video. For example, [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-FIG-5|Figure 8-5]] shows the rather psychedelic effect of using the &amp;lt;tt&amp;gt;srcBic&amp;lt;/tt&amp;gt; mode.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-FIG-5&amp;quot;&amp;gt;&lt;br /&gt;
'''Figure 8-5. Composited video tracks with srcBic graphics mode'''&lt;br /&gt;
&lt;br /&gt;
[[Image:QuickTime for Java: A Developer's Notebook_I_8_tt217.png|Composited video tracks with srcBic graphics mode]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What about... ===&lt;br /&gt;
&lt;br /&gt;
...practical uses for this? Granted, compositing two full-frame natural images is atypical, but composited video is used all the time in TV production. Modern video often represents many layers of overlapping sources. Watch a football game and you might see a shot of the game, overlaid by a graphic of a player and his stats (and maybe a video &amp;quot;head shot&amp;quot; of him), overlaid with a scoreboard for the corner, overlaid with a moving &amp;quot;bug&amp;quot; of the network's logo in another corner. Each source contains some amount of &amp;quot;useful&amp;quot; video, and the rest is a solid color (often black for synthetic video, green or blue for real-world video). The solid color becomes transparent, so only the useful data is copied over to the target. In terms of &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt;s, this would be the transparent mode, with the specified color as the operand.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;tip&amp;quot;&amp;gt;&lt;br /&gt;
'''Tip'''&lt;br /&gt;
&lt;br /&gt;
If you're serious about shooting bluescreen video, there are sites on the Internet that list the supplies you'll need. For example, ''http://www.studiodepot.com/'' sells chroma-key-friendly fabric and tape for making bluescreen and greenscreen backdrops.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Building a Video Track from Raw Samples ==&lt;br /&gt;
&lt;br /&gt;
You can create a video track &amp;quot;from scratch&amp;quot; by adding video samples, one by one, to the video media. This is perhaps the ultimate in low-level access to QuickTime video, because it makes you responsible for every pixel in every frame. One way to demonstrate this is by making a movie from a still image and using slightly different parts of it in each frame to suggest a camera moving across the image.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;tip&amp;quot;&amp;gt;&lt;br /&gt;
'''Tip'''&lt;br /&gt;
&lt;br /&gt;
This concept is called the &amp;quot;Ken Burns Effect&amp;quot; in Apple's iMovie, after the documentary filmmaker who used the technique extensively in documentaries like ''The Civil War'', for which no film or video sources were available.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How do I do that? ===&lt;br /&gt;
&lt;br /&gt;
To build a movie from samples taken from an image, use the following approach:&lt;br /&gt;
&lt;br /&gt;
# Import an image.&lt;br /&gt;
# Pick source and destination rectangles.&lt;br /&gt;
# Calculate a series of rectangles between the source and destination. These represent which part of the source image will be used for each frame.&lt;br /&gt;
# Create an empty movie, new video track, and new video media.&lt;br /&gt;
# Use a &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; to convert each source rectangle to the size of the movie.&lt;br /&gt;
# Compress each frame and add it to the &amp;lt;tt&amp;gt;VideoMedia&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You might already know how to do some of this; the new part is how to compress frames into a movie. [[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]] made use of the &amp;lt;tt&amp;gt;QTImage.compress( )&amp;lt;/tt&amp;gt; method to compress &amp;lt;tt&amp;gt;QDGraphics&amp;lt;/tt&amp;gt; (a.k.a. &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;s) into &amp;lt;tt&amp;gt;EncodedImage&amp;lt;/tt&amp;gt;s, but video is a little different in that you use a &amp;lt;tt&amp;gt;CSequence&amp;lt;/tt&amp;gt;, short for ''compression sequence''. The difference is that in many video compression formats, you may need information from previous or subsequent frames to render a specific frame. In other words, some frames are encoded as just the data that has changed from a previous frame. So, you can't compress a single image in isolation; you must work with a sequence of images. This is called ''temporal compression'' because it is time-based.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;VideoSampleBuilder&amp;lt;/tt&amp;gt; demo, shown in [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-EX-2|Example 8-2]], creates a movie called ''videotrack.mov'' from a source graphic.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;tip&amp;quot;&amp;gt;&lt;br /&gt;
'''Tip'''&lt;br /&gt;
&lt;br /&gt;
This is the most involved example in the book and uses concepts from several chapters, such as enabling editing and adding a new &amp;lt;tt&amp;gt;Track&amp;lt;/tt&amp;gt; ([[QuickTime for Java: A Developer's Notebook/Editing Movies|Chapter 3]]), using a &amp;lt;tt&amp;gt;GraphicsImporter&amp;lt;/tt&amp;gt; ([[QuickTime for Java: A Developer's Notebook/Working with Components|Chapter 4]]), setting up an off-screen &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt; ([[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]]), using &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt;-based image manipulation ([[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]] and this chapter), and adding raw samples to a &amp;lt;tt&amp;gt;Media&amp;lt;/tt&amp;gt; (a sound equivalent was shown in [[QuickTime for Java: A Developer's Notebook/Audio Media|Chapter 7]]). So, don't be intimidated if it seems a little complicated the first time you read it.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-EX-2&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 8-2. Building a video track from image samples'''&lt;br /&gt;
&lt;br /&gt;
 package com.oreilly.qtjnotebook.ch08;&lt;br /&gt;
  &lt;br /&gt;
 import quicktime.*;&lt;br /&gt;
 import quicktime.io.*;&lt;br /&gt;
 import quicktime.util.QTPointer;&lt;br /&gt;
 import quicktime.qd.*;&lt;br /&gt;
 import quicktime.std.*;&lt;br /&gt;
 import quicktime.std.movies.*;&lt;br /&gt;
 import quicktime.std.movies.media.*;&lt;br /&gt;
 import quicktime.std.image.*;&lt;br /&gt;
 import quicktime.util.*;&lt;br /&gt;
  &lt;br /&gt;
 import com.oreilly.qtjnotebook.ch01.QTSessionCheck;&lt;br /&gt;
  &lt;br /&gt;
 import java.io.*;&lt;br /&gt;
 import java.util.Random;&lt;br /&gt;
 import java.util.Properties;&lt;br /&gt;
  &lt;br /&gt;
 public class VideoSampleBuilder extends Object {&lt;br /&gt;
  &lt;br /&gt;
   public static final int VIDEO_TRACK_WIDTH = 320;&lt;br /&gt;
   public static final int VIDEO_TRACK_HEIGHT = 240;&lt;br /&gt;
   public static final int VIDEO_TRACK_VOLUME = 0;&lt;br /&gt;
   public static final int KEY_FRAME_RATE = 30;&lt;br /&gt;
  &lt;br /&gt;
   Properties userProps = new Properties( );&lt;br /&gt;
   QDRect startRect = null;&lt;br /&gt;
   QDRect endRect = null;&lt;br /&gt;
  &lt;br /&gt;
   public VideoSampleBuilder( ) throws QTException, IOException {&lt;br /&gt;
  &lt;br /&gt;
       /* try to load &amp;quot;videoSampleBuilder.properties&amp;quot; from &lt;br /&gt;
          current directory.  this contains file.location and&lt;br /&gt;
          start.x/y/width/height and end.x/y/width/height params&lt;br /&gt;
        */&lt;br /&gt;
       try {&lt;br /&gt;
           userProps.load (new FileInputStream (&lt;br /&gt;
               new File (&amp;quot;videosamplebuilder.properties&amp;quot;)));&lt;br /&gt;
           System.out.println (&amp;quot;Loaded properties&amp;quot;);&lt;br /&gt;
       } catch (Exception e) {&lt;br /&gt;
           System.out.println (&amp;quot;Couldn't load properties&amp;quot;);&lt;br /&gt;
       }&lt;br /&gt;
  &lt;br /&gt;
       int CODEC_TYPE = QTUtils.toOSType (&amp;quot;SVQ3&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
       // create a new empty movie&lt;br /&gt;
       QTFile movFile = new QTFile (new java.io.File(&amp;quot;videotrack.mov&amp;quot;));&lt;br /&gt;
       Movie movie =&lt;br /&gt;
           Movie.createMovieFile(movFile,&lt;br /&gt;
                  StdQTConstants.kMoviePlayer,&lt;br /&gt;
                  StdQTConstants.createMovieFileDeleteCurFile |&lt;br /&gt;
                  StdQTConstants.createMovieFileDontCreateResFile);&lt;br /&gt;
       System.out.println (&amp;quot;Created Movie&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
       // now create an empty video track&lt;br /&gt;
       int timeScale = 600; // 100 units per second&lt;br /&gt;
       Track videoTrack = movie.addTrack (VIDEO_TRACK_WIDTH,&lt;br /&gt;
                                          VIDEO_TRACK_HEIGHT,&lt;br /&gt;
                                          VIDEO_TRACK_VOLUME);&lt;br /&gt;
       System.out.println (&amp;quot;Added empty Track&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
       // now we need media for this track&lt;br /&gt;
       VideoMedia videoMedia = new VideoMedia(videoTrack,&lt;br /&gt;
                                              timeScale);&lt;br /&gt;
  &lt;br /&gt;
       // get image file from props or dialog&lt;br /&gt;
       QTFile imgFile = getImageFile( );&lt;br /&gt;
       if (imgFile =  = null)&lt;br /&gt;
           return;&lt;br /&gt;
  &lt;br /&gt;
       // get a GraphicsImporter&lt;br /&gt;
       GraphicsImporter importer = new GraphicsImporter (imgFile);&lt;br /&gt;
       System.out.println (&amp;quot;Got GraphicsImporter - Bounds are &amp;quot; +&lt;br /&gt;
                           importer.getNaturalBounds( ));&lt;br /&gt;
  &lt;br /&gt;
       // Create an offscreen QDGraphics / GWorld that's the&lt;br /&gt;
       // size of our frames.  Importer will draw into this,&lt;br /&gt;
       // and we'll then hand it to the CSequence&lt;br /&gt;
       QDGraphics gw =&lt;br /&gt;
           new QDGraphics (new QDRect (0, 0,&lt;br /&gt;
                                       VIDEO_TRACK_WIDTH,&lt;br /&gt;
                                       VIDEO_TRACK_HEIGHT));&lt;br /&gt;
       System.out.println (&amp;quot;Created GWorld, - Bounds are &amp;quot; +&lt;br /&gt;
                           gw.getBounds( ));&lt;br /&gt;
  &lt;br /&gt;
       // get start, end rects&lt;br /&gt;
       getRects (importer);&lt;br /&gt;
       System.out.println (&amp;quot;startRect = &amp;quot; + startRect);&lt;br /&gt;
       System.out.println (&amp;quot;endRect = &amp;quot; + endRect);&lt;br /&gt;
  &lt;br /&gt;
       // set importer's gworld&lt;br /&gt;
       importer.setGWorld (gw, null);&lt;br /&gt;
       System.out.println (&amp;quot;Reset importer's GWorld, now: &amp;quot; +&lt;br /&gt;
                           importer.getGWorld( ));&lt;br /&gt;
                           &lt;br /&gt;
       // get to work&lt;br /&gt;
       videoMedia.beginEdits( );&lt;br /&gt;
  &lt;br /&gt;
       // figure out per-frame offsets&lt;br /&gt;
       QDRect gRect = new QDRect (0, 0,&lt;br /&gt;
                                     VIDEO_TRACK_WIDTH,&lt;br /&gt;
                                     VIDEO_TRACK_HEIGHT);&lt;br /&gt;
       int frames = 300;&lt;br /&gt;
       int startX = startRect.getX( );&lt;br /&gt;
       int startY = startRect.getY( );&lt;br /&gt;
       int endX = endRect.getX( );&lt;br /&gt;
       int endY = endRect.getY( );&lt;br /&gt;
       float xOffPerFrame = ((float)(endX - startX) / (float)frames);&lt;br /&gt;
       float yOffPerFrame = ((float)(endY - startY) / (float)frames);&lt;br /&gt;
       float widthOffPerFrame = ((float) (endRect.getWidth( ) -&lt;br /&gt;
                                          startRect.getWidth( )) /&lt;br /&gt;
                                 (float) frames);&lt;br /&gt;
       float heightOffPerFrame = ((float) (endRect.getHeight( ) -&lt;br /&gt;
                                          startRect.getHeight( )) /&lt;br /&gt;
                                 (float) frames);&lt;br /&gt;
  &lt;br /&gt;
       System.out.println (&amp;quot;xOffPerFrame=&amp;quot; + xOffPerFrame +&lt;br /&gt;
                           &amp;quot;, yOffPerFrame=&amp;quot; + yOffPerFrame +&lt;br /&gt;
                           &amp;quot;, widthOffPerFrame=&amp;quot; + widthOffPerFrame +&lt;br /&gt;
                           &amp;quot;, heightOffPerFrame=&amp;quot; + heightOffPerFrame);&lt;br /&gt;
  &lt;br /&gt;
       // reserve an image with enough space to hold compressed image&lt;br /&gt;
       // this is needed by the last arg of CSequence.compressFrame&lt;br /&gt;
       int rawImageSize =&lt;br /&gt;
           QTImage.getMaxCompressionSize (gw, &lt;br /&gt;
                                          gRect, &lt;br /&gt;
                                          gw.getPixMap( ).getPixelSize( ),&lt;br /&gt;
                                          StdQTConstants.codecNormalQuality, &lt;br /&gt;
                                          CODEC_TYPE,&lt;br /&gt;
                                          CodecComponent.bestFidelityCodec);&lt;br /&gt;
       QTHandle imageHandle = new QTHandle (rawImageSize, true);&lt;br /&gt;
       imageHandle.lock( );&lt;br /&gt;
       RawEncodedImage compressedImage =&lt;br /&gt;
           RawEncodedImage.fromQTHandle(imageHandle);&lt;br /&gt;
  &lt;br /&gt;
       // create a CSequence&lt;br /&gt;
       CSequence seq = new CSequence (gw,&lt;br /&gt;
                                      gRect, &lt;br /&gt;
                                      gw.getPixMap( ).getPixelSize( ),&lt;br /&gt;
                                      CODEC_TYPE,&lt;br /&gt;
                                      CodecComponent.bestFidelityCodec,&lt;br /&gt;
                                      StdQTConstants.codecNormalQuality, &lt;br /&gt;
                                      StdQTConstants.codecNormalQuality, &lt;br /&gt;
                                      KEY_FRAME_RATE,&lt;br /&gt;
                                      null,&lt;br /&gt;
                                      StdQTConstants.codecFlagUpdatePrevious);&lt;br /&gt;
  &lt;br /&gt;
       // remember an ImageDescription from this sequence definition&lt;br /&gt;
       ImageDescription imgDesc = seq.getDescription( );&lt;br /&gt;
  &lt;br /&gt;
       // loop through the specified number of frames, drawing &lt;br /&gt;
       // scaled instances into our GWorld and compressing those&lt;br /&gt;
       // to the CSequence&lt;br /&gt;
       for (int i=1; i&amp;lt;frames; i++) {&lt;br /&gt;
           System.out.println (&amp;quot;i=  =&amp;quot; + i);&lt;br /&gt;
  &lt;br /&gt;
           // compute a rect for this frame&lt;br /&gt;
           int x = startX + (int) (xOffPerFrame * i);&lt;br /&gt;
           int y = startY + (int) (yOffPerFrame * i);&lt;br /&gt;
           int width = startRect.getWidth( ) + (int) (widthOffPerFrame * i);&lt;br /&gt;
           int height = startRect.getHeight( ) + (int) (heightOffPerFrame * i);&lt;br /&gt;
           QDRect fromRect = new QDRect (x, y, width, height);&lt;br /&gt;
  &lt;br /&gt;
           // create a Matrix to represent the move/scale from&lt;br /&gt;
           // the fromRect to the GWorld and make importer use it&lt;br /&gt;
           Matrix drawMatrix = new Matrix( );&lt;br /&gt;
           drawMatrix.rect (fromRect, gRect);&lt;br /&gt;
           System.out.println (&amp;quot;fromRect = &amp;quot; + fromRect);&lt;br /&gt;
           importer.setMatrix (drawMatrix);&lt;br /&gt;
  &lt;br /&gt;
           // have importer draw (scaled) into our GWorld&lt;br /&gt;
           importer.draw( );&lt;br /&gt;
           System.out.println (&amp;quot;Importer drew&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
           // compress a frame&lt;br /&gt;
           CompressedFrameInfo cfInfo =&lt;br /&gt;
               seq.compressFrame (gw, &lt;br /&gt;
                                  gRect, &lt;br /&gt;
                                  StdQTConstants.codecFlagUpdatePrevious, &lt;br /&gt;
                                  compressedImage);&lt;br /&gt;
           System.out.println (&amp;quot;similarity = &amp;quot; + cfInfo.getSimilarity( ));&lt;br /&gt;
  &lt;br /&gt;
           // is this a key frame?&lt;br /&gt;
           boolean syncSample = (cfInfo.getSimilarity( ) =  = 0);&lt;br /&gt;
           int flags = syncSample ? 0 : StdQTConstants.mediaSampleNotSync;&lt;br /&gt;
  &lt;br /&gt;
           // add compressed frame to the video media&lt;br /&gt;
           videoMedia.addSample (imageHandle, &lt;br /&gt;
                                 0, &lt;br /&gt;
                                 cfInfo.getDataSize( ),&lt;br /&gt;
                                 20, // time per frame, in timescale&lt;br /&gt;
                                 imgDesc,&lt;br /&gt;
                                 1, // one sample&lt;br /&gt;
                                 flags&lt;br /&gt;
                                 );&lt;br /&gt;
       } // for&lt;br /&gt;
  &lt;br /&gt;
       // done editing&lt;br /&gt;
       videoMedia.endEdits( );&lt;br /&gt;
  &lt;br /&gt;
       // now insert this media into track&lt;br /&gt;
       videoTrack.insertMedia (0, // trackStart&lt;br /&gt;
                               0, // mediaTime&lt;br /&gt;
                               videoMedia.getDuration( ), // mediaDuration&lt;br /&gt;
                               1); // mediaRate&lt;br /&gt;
       System.out.println (&amp;quot;inserted media into video track&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
       // save up &lt;br /&gt;
       System.out.println (&amp;quot;Saving...&amp;quot;);&lt;br /&gt;
       OpenMovieFile omf = OpenMovieFile.asWrite (movFile);&lt;br /&gt;
       movie.addResource (omf,&lt;br /&gt;
                          StdQTConstants.movieInDataForkResID,&lt;br /&gt;
                          movFile.getName( ));&lt;br /&gt;
       System.out.println (&amp;quot;Done&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
   }&lt;br /&gt;
  &lt;br /&gt;
   /** Gets imageFile from props file, or file-preview if &lt;br /&gt;
       that doesn't work.&lt;br /&gt;
    */&lt;br /&gt;
   protected QTFile getImageFile ( ) throws QTException {&lt;br /&gt;
       // is it in the props?&lt;br /&gt;
       QTFile imageFile = null;&lt;br /&gt;
       if (userProps.containsKey (&amp;quot;file&amp;quot;)) {&lt;br /&gt;
           imageFile = new QTFile (userProps.getProperty(&amp;quot;file&amp;quot;));&lt;br /&gt;
           if (! imageFile.exists( ))&lt;br /&gt;
               imageFile = null;&lt;br /&gt;
       }&lt;br /&gt;
  &lt;br /&gt;
       // if not, or if that failed, then use a dialog&lt;br /&gt;
       if (imageFile =  = null) {&lt;br /&gt;
           int[  ] types = {  };&lt;br /&gt;
           imageFile = QTFile.standardGetFilePreview (types);&lt;br /&gt;
       }&lt;br /&gt;
       return imageFile;&lt;br /&gt;
   }&lt;br /&gt;
  &lt;br /&gt;
   /** Gets startRect, endRect from userProps, or selects&lt;br /&gt;
       randomly if that doesn't work&lt;br /&gt;
    */&lt;br /&gt;
   protected void getRects (GraphicsImporter importer) throws QTException {&lt;br /&gt;
       Random rand = new Random( );&lt;br /&gt;
       int rightStop =&lt;br /&gt;
           importer.getNaturalBounds( ).getWidth( ) - VIDEO_TRACK_WIDTH;&lt;br /&gt;
       int bottomStop =&lt;br /&gt;
           importer.getNaturalBounds( ).getHeight( ) - VIDEO_TRACK_HEIGHT;&lt;br /&gt;
  &lt;br /&gt;
       // try to get startRect from userProps&lt;br /&gt;
       try {&lt;br /&gt;
           int startX = Integer.parseInt (userProps.getProperty(&amp;quot;start.x&amp;quot;));&lt;br /&gt;
           int startY = Integer.parseInt (userProps.getProperty(&amp;quot;start.y&amp;quot;));&lt;br /&gt;
           int startWidth = &lt;br /&gt;
               Integer.parseInt (userProps.getProperty(&amp;quot;start.width&amp;quot;));&lt;br /&gt;
           int startHeight = &lt;br /&gt;
               Integer.parseInt (userProps.getProperty(&amp;quot;start.height&amp;quot;));&lt;br /&gt;
           startRect = new QDRect (startX, startY, startWidth, startHeight);&lt;br /&gt;
       } catch (Exception e) {&lt;br /&gt;
           // make random start rect&lt;br /&gt;
           int startX = Math.abs (rand.nextInt( ) % rightStop);&lt;br /&gt;
           int startY = Math.abs (rand.nextInt( ) % bottomStop);&lt;br /&gt;
           startRect = new QDRect (startX, startY, &lt;br /&gt;
                                   VIDEO_TRACK_WIDTH,&lt;br /&gt;
                                   VIDEO_TRACK_HEIGHT);&lt;br /&gt;
       }&lt;br /&gt;
  &lt;br /&gt;
       // try to get endRect from userProps&lt;br /&gt;
       try {&lt;br /&gt;
           int endX = Integer.parseInt (userProps.getProperty(&amp;quot;end.x&amp;quot;));&lt;br /&gt;
           int endY = Integer.parseInt (userProps.getProperty(&amp;quot;end.y&amp;quot;));&lt;br /&gt;
           int endWidth = Integer.parseInt (userProps.getProperty(&amp;quot;end.width&amp;quot;));&lt;br /&gt;
           int endHeight = Integer.parseInt (userProps.getProperty(&amp;quot;end.height&amp;quot;));&lt;br /&gt;
           endRect = new QDRect (endX, endY, endWidth, endHeight);&lt;br /&gt;
  &lt;br /&gt;
       } catch (Exception e) {&lt;br /&gt;
           float zoom = (rand.nextFloat( ) - 0.5f); // -0.5 &amp;lt;= zoom &amp;lt;= 0.5&lt;br /&gt;
           System.out.println (&amp;quot;zoom = &amp;quot; + zoom);&lt;br /&gt;
           int endX = Math.abs (rand.nextInt( ) % rightStop);&lt;br /&gt;
           int endY = Math.abs (rand.nextInt( ) % bottomStop);&lt;br /&gt;
           endRect = new QDRect (endX, endY,&lt;br /&gt;
                                 VIDEO_TRACK_WIDTH * zoom,&lt;br /&gt;
                                 VIDEO_TRACK_HEIGHT * zoom);&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
  &lt;br /&gt;
   public static void main (String[  ] arrrImAPirate) {&lt;br /&gt;
       try {&lt;br /&gt;
           QTSessionCheck.check( );&lt;br /&gt;
           new VideoSampleBuilder( );&lt;br /&gt;
       } catch (Exception e) {&lt;br /&gt;
           e.printStackTrace( );&lt;br /&gt;
       }&lt;br /&gt;
       System.exit(0);&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Run this demo with ant run-ch08-videosamplebuilder''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When run, the demo looks for a file called ''videosamplebuilder.properties'' , in which you can define the source image and the start and end rectangles. The properties file should have entries like this:&lt;br /&gt;
&lt;br /&gt;
 file=/Users/cadamson/Pictures/keagy/DSC01763.jpg&lt;br /&gt;
  &lt;br /&gt;
 start.x=545&lt;br /&gt;
 start.y=370&lt;br /&gt;
 start.width=1500&lt;br /&gt;
 start.height=1125&lt;br /&gt;
  &lt;br /&gt;
 end.x=400&lt;br /&gt;
 end.y=390&lt;br /&gt;
 end.width=800&lt;br /&gt;
 end.height=600&lt;br /&gt;
&lt;br /&gt;
If no properties file is found, the demo queries the user for an image and randomly selects the start and end rectangles.&lt;br /&gt;
&lt;br /&gt;
As each frame is compressed, the program prints an update to the console indicating the frame count, the source frame, and how &amp;quot;similar&amp;quot; the &amp;lt;tt&amp;gt;CSequence&amp;lt;/tt&amp;gt; decided the frame was to its predecessor. The console log looks something like this:&lt;br /&gt;
&lt;br /&gt;
 cadamson% ant run-ch08-videosamplebuilder&lt;br /&gt;
 Buildfile: build.xml&lt;br /&gt;
  &lt;br /&gt;
 run-ch08-videosamplebuilder:&lt;br /&gt;
  [java] Couldn't load properties&lt;br /&gt;
  [java] Created Movie&lt;br /&gt;
  [java] Added empty Track&lt;br /&gt;
  [java] Got GraphicsImporter - Bounds are quicktime.qd.QDRect[x=0.0,y=0.0,width=800.0,&lt;br /&gt;
 height=600.0]&lt;br /&gt;
  [java] Created GWorld, - Bounds are quicktime.qd.QDRect[x=0.0,y=0.0,width=320.0,&lt;br /&gt;
 height=240.0]&lt;br /&gt;
  [java] zoom = -0.45799363&lt;br /&gt;
  [java] startRect = quicktime.qd.QDRect[x=158.0,y=30.0,width=320.0,height=240.0]&lt;br /&gt;
  [java] endRect = quicktime.qd.QDRect[x=282.0,y=158.0,width=146.55795,height=109.91846]&lt;br /&gt;
  [java] Reset importer's GWorld, now: quicktime.qd.QDGraphics@8f10820[size=108]&lt;br /&gt;
 [PortRect=quicktime.qd.QDRect[x=0.0,y=0.0,width=320.0,height=240.0],isOffscreen=true]&lt;br /&gt;
  [java] xOffPerFrame=0.41333333, yOffPerFrame=0.42666668, widthOffPerFrame=-0.58, &lt;br /&gt;
 heightOffPerFrame=-0.43666667&lt;br /&gt;
  [java] i=  =1&lt;br /&gt;
  [java] fromRect = quicktime.qd.QDRect[x=158.0,y=30.0,width=320.0,height=240.0]&lt;br /&gt;
  [java] Importer drew&lt;br /&gt;
  [java] similarity = 0&lt;br /&gt;
  [java] i=  =2&lt;br /&gt;
  [java] fromRect = quicktime.qd.QDRect[x=158.0,y=30.0,width=319.0,height=240.0]&lt;br /&gt;
  [java] Importer drew&lt;br /&gt;
  [java] similarity = 128&lt;br /&gt;
&lt;br /&gt;
When finished, you can play the ''videotrack.mov'' file in QuickTime Player, the player and editor examples in Chapters [[QuickTime for Java: A Developer's Notebook/Playing Movies|Chapter 2]] and [[QuickTime for Java: A Developer's Notebook/Editing Movies|Chapter 3]], or equivalent. [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-FIG-6|Figure 8-6]] shows two screenshots from different times in the movie to indicate the zoom effect that is created by using different parts of the picture.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-FIG-6&amp;quot;&amp;gt;&lt;br /&gt;
'''Figure 8-6. Movie built via addSample( ) from portions of a static image'''&lt;br /&gt;
&lt;br /&gt;
[[Image:QuickTime for Java: A Developer's Notebook_I_8_tt220.png|Movie built via addSample( ) from portions of a static image]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What just happened? ===&lt;br /&gt;
&lt;br /&gt;
One of the first things to notice is the constant &amp;lt;tt&amp;gt;CODEC_TYPE&amp;lt;/tt&amp;gt; , which is used later on in setting up the &amp;lt;tt&amp;gt;CSequence&amp;lt;/tt&amp;gt;. This indicates which of the supported QuickTime video codecs is to be used for the video track. The codec is indicated by a &amp;lt;tt&amp;gt;FOUR_CHAR_CODE&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;, in this case &amp;quot;&amp;lt;tt&amp;gt;SVQ3&amp;lt;/tt&amp;gt;&amp;quot;, which identifies the Sorenson Video 3 codec. Most of the usable codecs exist as constants in the &amp;lt;tt&amp;gt;StdQTConstants&amp;lt;/tt&amp;gt; classes—for example, I could have put this as &amp;lt;tt&amp;gt;StdQTConstants6.kSorenson3CodecType&amp;lt;/tt&amp;gt;. The advantage of using the &amp;lt;tt&amp;gt;FOUR_CHAR_CODE&amp;lt;/tt&amp;gt; directly is that you can use any supported codec, even those that don't have constants defined in QTJ yet. In fact, Sorenson Video 3 and MPEG-4 video (&amp;lt;tt&amp;gt;StdQTConstants6.kMPEG4VisualCodecType&amp;lt;/tt&amp;gt;) didn't have constants in QTJ until I filed a bug report for them, and the Pixlet codec (whose 4CC is &amp;quot;&amp;lt;tt&amp;gt;pxlt&amp;lt;/tt&amp;gt;&amp;quot;) still doesn't, as of this writing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;tip&amp;quot;&amp;gt;&lt;br /&gt;
'''Tip'''&lt;br /&gt;
&lt;br /&gt;
&amp;quot;So, what's the best codec?&amp;quot; I hear someone asking. Don't go there. There's no such thing as a best codec. There are so many different codecs, because they're engineered to serve different purposes. For example, some codecs are difficult to compress (in terms of CPU power, encoder expertise, etc.) but easy to decompress, making them well suited for mass-distribution media like DVDs where the encoding is done only once. On the other hand, a codec used for video conferencing must be light enough to do on the fly, with minimal configuration. Others are tuned to specific bitrates and uses, losing their advantages outside their preferred realm. The new MPEG-4 codec, H.264 (AVC), claims to be able to scale from cell phone to HDTV bandwidths...we'll see if it delivers on this.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build the image movie, create an empty movie file, add a track, and create a &amp;lt;tt&amp;gt;VideoMedia&amp;lt;/tt&amp;gt; for the track. You do this by creating a &amp;lt;tt&amp;gt;Movie&amp;lt;/tt&amp;gt; with the constructor that takes a file reference (so that QuickTime knows where to put the samples you'll be adding), calling &amp;lt;tt&amp;gt;Movie.addTrack( )&amp;lt;/tt&amp;gt; to create the track, and constructing a &amp;lt;tt&amp;gt;VideoMedia&amp;lt;/tt&amp;gt;. Then call &amp;lt;tt&amp;gt;Media.beginEdits( )&amp;lt;/tt&amp;gt; to signal that you're going to be altering the &amp;lt;tt&amp;gt;VideoMedia&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''These steps are similar to those in [[QuickTime for Java: A Developer's Notebook/Audio Media|Chapter 7]] s square-wave sample-building example''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next step is to get the image with a &amp;lt;tt&amp;gt;GraphicsImporter&amp;lt;/tt&amp;gt;. This will be the source of every frame of the movie. However, it's not the right size. So create an off-screen &amp;lt;tt&amp;gt;QDGraphics&amp;lt;/tt&amp;gt; (a.k.a. &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;, the term used in the native API and all its getters and setters in QTJ) with the desired movie dimensions. By calling &amp;lt;tt&amp;gt;GraphicsImporter.setGWorld()&amp;lt;/tt&amp;gt; , you tell the importer that subsequent calls to &amp;lt;tt&amp;gt;draw()&amp;lt;/tt&amp;gt; will draw pixels from the imported graphic into the off-screen &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;, which will be the source of the compressed frames later on.&lt;br /&gt;
&lt;br /&gt;
Next, after calculating how far the source rectangle will move each frame, you set up the compression sequence. To do this, you need a buffer big enough to hold compressed images, which in turn requires a call to figure out how big that buffer needs to be. &amp;lt;tt&amp;gt;QTImage.getMaxCompression()&amp;lt;/tt&amp;gt; size provides this size. You need to pass in the following data (in the order shown):&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;QDGraphics&amp;lt;/tt&amp;gt;/&amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt; to compress from.&lt;br /&gt;
# A &amp;lt;tt&amp;gt;QDRect&amp;lt;/tt&amp;gt; indicating what part of the &amp;lt;tt&amp;gt;QDGraphics&amp;lt;/tt&amp;gt; will be used.&lt;br /&gt;
# The color depth of the pixels (i.e., how many bits are in each pixel).&lt;br /&gt;
# A constant to indicate the compressed image quality level.&lt;br /&gt;
# The codec's &amp;lt;tt&amp;gt;FOUR_CHAR_CODE&amp;lt;/tt&amp;gt; .&lt;br /&gt;
# A constant to indicate which codec component to pick if several can handle the codec. You can pass a specific component, or the behavior constants &amp;lt;tt&amp;gt;anyCodec&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bestSpeedCodec&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bestFidelityCodec&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;bestCompressionCodec&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Given this, you can allocate memory for the image by constructing a new &amp;lt;tt&amp;gt;QTHandle&amp;lt;/tt&amp;gt;, and then wrap it with a &amp;lt;tt&amp;gt;RawEncodedImage&amp;lt;/tt&amp;gt; object. This is where the compressed frames will go.&lt;br /&gt;
&lt;br /&gt;
Now you have enough information to create the &amp;lt;tt&amp;gt;CSequence&amp;lt;/tt&amp;gt; . Its constructor takes a whopping 10 arguments:&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;tt&amp;gt;QDGraphics&amp;lt;/tt&amp;gt;/&amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt; to compress from&lt;br /&gt;
* A &amp;lt;tt&amp;gt;QDRect&amp;lt;/tt&amp;gt; indicating what part of the &amp;lt;tt&amp;gt;QDGraphics&amp;lt;/tt&amp;gt; will be used&lt;br /&gt;
* The color depth of the pixels (i.e., how many bits are in each pixel)&lt;br /&gt;
* The codec's &amp;lt;tt&amp;gt;FOUR_CHAR_CODE&amp;lt;/tt&amp;gt;&lt;br /&gt;
* A specific codec component or a selection strategy constant (&amp;lt;tt&amp;gt;anyCodec&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bestSpeedCodec&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
* Spatial quality (in other words, the quality of images after 2D compression, using one of the constants &amp;lt;tt&amp;gt;codecMinQuality&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;codecLowQuality&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;codecNormalQuality&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;codecHighQuality&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;codecMaxQuality&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;codecLosslessQuality&amp;lt;/tt&amp;gt;)&lt;br /&gt;
* Temporal quality (this uses the same constants as for spatial quality, but refers to quality maintained or lost when using data from adjacent frames; you also can set this to &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt; to not use temporal compression)&lt;br /&gt;
* Key frame rate (the maximum number of frames allowed between &amp;quot;key frames&amp;quot; [those that have all image data for a frame and don't depend on other frames], or &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt; to not use key frames)&lt;br /&gt;
* A custom color lookup table, or &amp;lt;tt&amp;gt;null&amp;lt;/tt&amp;gt; to use the table from the source image&lt;br /&gt;
* Behavior flags (these can include the &amp;lt;tt&amp;gt;codecFlagWasCompressed&amp;lt;/tt&amp;gt; flag, which indicates the source image was previously compressed and asks the codec to compensate, and &amp;lt;tt&amp;gt;codecFlagUpdatePrevious&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;codecFlagUpdatePreviousComp&amp;lt;/tt&amp;gt;, both of which hold on to previously compressed frames for temporal-compression codecs, the latter of which may produce better results but consumes more CPU power)&lt;br /&gt;
&lt;br /&gt;
Now you've got everything you need to build the frames: a &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt; for source images, a &amp;lt;tt&amp;gt;RawEncodedImage&amp;lt;/tt&amp;gt; to compress into, a &amp;lt;tt&amp;gt;CSequence&amp;lt;/tt&amp;gt; to compress frames, and a &amp;lt;tt&amp;gt;VideoMedia&amp;lt;/tt&amp;gt; to put them into.&lt;br /&gt;
&lt;br /&gt;
So, start looping. Each time through the loop, you draw a different part of the source image into the off-screen &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;. This is done by resetting the &amp;lt;tt&amp;gt;GraphicImporter&amp;lt;/tt&amp;gt;'s &amp;lt;tt&amp;gt;Matrix&amp;lt;/tt&amp;gt; , using &amp;lt;tt&amp;gt;rect( )&amp;lt;/tt&amp;gt; to scale-and-translate from a source rectangle to a new rectangle at (0,0) and with the dimensions of the off-screen &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;. Use &amp;lt;tt&amp;gt;GraphicsImporter.draw( )&amp;lt;/tt&amp;gt; to draw from the source image into the &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
With the frame's pixels in the &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt;, call &amp;lt;tt&amp;gt;CSequence.compressFrame()&amp;lt;/tt&amp;gt; to compress the pixels into the &amp;lt;tt&amp;gt;RawEncodedImage&amp;lt;/tt&amp;gt; . This returns a &amp;lt;tt&amp;gt;CompressedFrameInfo&amp;lt;/tt&amp;gt; object that wraps the size of the compressed image and a &amp;quot;similarity&amp;quot; value that represents the similarity or difference between the current frame and the previous frame. The similarity is used to determine if this sample is a &amp;quot;key frame&amp;quot; (also called a &amp;quot;sync sample&amp;quot; in Apple's terminology), which in this context means an image so different from its predecessors that the compressor should encode all the data for this image in this frame instead of depending on any previous frames.&lt;br /&gt;
&lt;br /&gt;
Finally, you call &amp;lt;tt&amp;gt;addSample()&amp;lt;/tt&amp;gt; to add the frame to the &amp;lt;tt&amp;gt;VideoMedia&amp;lt;/tt&amp;gt;. This call, inherited from &amp;lt;tt&amp;gt;Media&amp;lt;/tt&amp;gt;, takes a pointer to the sample data, an offset into the data, the data size, the time represented by the sample (in the media's time scale), a description of the data (here an &amp;lt;tt&amp;gt;ImageDescription&amp;lt;/tt&amp;gt; retrieved from the &amp;lt;tt&amp;gt;CSequence&amp;lt;/tt&amp;gt;), the number of samples being added with the call, and a flag that indicates whether this sample is a key frame (if it's not, pass &amp;lt;tt&amp;gt;StdQTConstants.mediaSampleNotSync&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Notice addSample( ) has the same signature for any kind of media. That's why it needs a parameter like the ImageDescription to explain what's in the essentially untyped QTHandle''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're done adding frames, call &amp;lt;tt&amp;gt;Media.endEdits( )&amp;lt;/tt&amp;gt; , then insert the media into the track with &amp;lt;tt&amp;gt;Track.insertMedia()&amp;lt;/tt&amp;gt; . Finally, save the movie with the &amp;lt;tt&amp;gt;Movie.addResource()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Run this demo with ant run-ch08-videosamplebuilder''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When run, the demo looks for a file called ''videosamplebuilder.properties'', in which you can define the source image and the start and end rectangles. The properties file should have entries like this:&lt;br /&gt;
&lt;br /&gt;
 file=/Users/cadamson/Pictures/keagy/DSC01763.jpg&lt;br /&gt;
  &lt;br /&gt;
 start.x=545&lt;br /&gt;
 start.y=370&lt;br /&gt;
 start.width=1500&lt;br /&gt;
 start.height=1125&lt;br /&gt;
  &lt;br /&gt;
 end.x=400&lt;br /&gt;
 end.y=390&lt;br /&gt;
 end.width=800&lt;br /&gt;
 end.height=600&lt;br /&gt;
&lt;br /&gt;
If no properties file is found, the demo queries the user for an image and randomly selects the start and end rectangles.&lt;br /&gt;
&lt;br /&gt;
As each frame is compressed, the program prints an update to the console indicating the frame count, the source frame, and how &amp;quot;similar&amp;quot; the &amp;lt;tt&amp;gt;CSequence&amp;lt;/tt&amp;gt; decided the frame was to its predecessor. The console log looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Did you notice the capture settings dialog in [[QuickTime for Java: A Developer's Notebook/Capture|Chapter 6]] showed a mirror image? You could use a Matrix to make the motion detector in that chapter render a mirror image, too''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overlaying Video Tracks ==&lt;br /&gt;
&lt;br /&gt;
When one video track is drawn on top of another, the top doesn't necessarily have to obscure the bottom. QuickTime gives you the option of specifying a &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; to combine pixels from multiple video layers to create interesting effects.&lt;br /&gt;
&lt;br /&gt;
=== How do I do that? ===&lt;br /&gt;
&lt;br /&gt;
You can create a &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; object to describe the means of combining overlapping colors. To try it out, take the previous lab's code and replace all the matrix stuff (after the &amp;lt;tt&amp;gt;foreTrack&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;backTrack&amp;lt;/tt&amp;gt; are created, but before the &amp;lt;tt&amp;gt;MovieController&amp;lt;/tt&amp;gt; is created) with the following:&lt;br /&gt;
&lt;br /&gt;
 GraphicsMode gm = new GraphicsMode (QDConstants.addMax,&lt;br /&gt;
                                   QDColor.green);&lt;br /&gt;
 VisualMediaHandler foreHandler = &lt;br /&gt;
   (VisualMediaHandler) foreTrack.getMedia( ).getHandler( );&lt;br /&gt;
 foreHandler.setGraphicsMode(gm);&lt;br /&gt;
 foreTrack.setLayer(-1);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Run this example with ant run-ch08-composit-evideotracks''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When run, this sample program asks you to open two movies, then creates a new movie with video tracks from the source movies' media, and combines the pixels of the foreground movie with the background, so the foreground appears atop the background. The result is shown in [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-FIG-4|Figure 8-4]].&lt;br /&gt;
&lt;br /&gt;
=== What just happened? ===&lt;br /&gt;
&lt;br /&gt;
Setting a &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; instructs QuickTime to apply a specific behavior to combine overlapping pixels. The &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; has a &amp;quot;mode&amp;quot; &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;, which indicates which kind of behavior to use, and a &amp;lt;tt&amp;gt;QDColor&amp;lt;/tt&amp;gt; that is used by some behaviors to indicate a color to operate on. For example, you might use mode &amp;lt;tt&amp;gt;QDConstants.transparent&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;QDColor.green&amp;lt;/tt&amp;gt; to make all green pixels transparent. The default mode is &amp;lt;tt&amp;gt;srcCopy&amp;lt;/tt&amp;gt;, which simply copies one set of pixels on top of another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''[[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]] showed how to set up GraphicsMode compositing of still images. Video works in pretty much the same way''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To apply this &amp;lt;tt&amp;gt;GraphicsMode&amp;lt;/tt&amp;gt; to overlapping video tracks, you call &amp;lt;tt&amp;gt;setGraphicsMode( )&amp;lt;/tt&amp;gt;, a method not defined by &amp;lt;tt&amp;gt;Track&amp;lt;/tt&amp;gt; but, rather, by the &amp;lt;tt&amp;gt;VideoMediaHandler&amp;lt;/tt&amp;gt;. As a reminder, movies have tracks, tracks have media, and media have handlers. Actually, the &amp;lt;tt&amp;gt;setGraphicsMode( )&amp;lt;/tt&amp;gt; is defined by the &amp;lt;tt&amp;gt;VisualMediaHandler&amp;lt;/tt&amp;gt; interface, making it available for all visual media (&amp;lt;tt&amp;gt;MPEGMedia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;TextMedia&amp;lt;/tt&amp;gt;, etc.).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Again, this wrap-up is the same as [[QuickTime for Java: A Developer's Notebook/Audio Media|Chapter 7]] s audio sample-building technique''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What about... ===&lt;br /&gt;
&lt;br /&gt;
...appropriate codecs to use? I've pointed out Sorenson Video 3 and MPEG-4 Visual, because they have very nice compression ratios and still look pretty good with natural images. Other codecs of interest in a standard QuickTime installation are shown in [[QuickTime for Java: A Developer's Notebook/Video Media#quicktimejvaadn-CHP-8-TABLE-1|Table 8-1]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;quicktimejvaadn-CHP-8-TABLE-1&amp;quot;&amp;gt;&lt;br /&gt;
'''Table 8-1. Some standard QuickTime codecs'''&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Name !! Constant !! 4CC !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Animation || &amp;lt;tt&amp;gt;kAnimationCodecType&amp;lt;/tt&amp;gt; || &amp;quot;&amp;lt;tt&amp;gt;rle&amp;lt;/tt&amp;gt;&amp;quot; || Good for long runs of solid colors, such as those found in simple synthetic 2D graphics.&lt;br /&gt;
|-&lt;br /&gt;
| Cinepak || &amp;lt;tt&amp;gt;kCinepakCodecType&amp;lt;/tt&amp;gt; || &amp;quot;&amp;lt;tt&amp;gt;cvid&amp;lt;/tt&amp;gt;&amp;quot; || This was the most popular codec of the early to mid-1990s, thanks to a good compression/quality tradeoff, wide support (even Sun's JMF handles it), and the fact that it could run on very modest CPUs. Today, there are better options.&lt;br /&gt;
|-&lt;br /&gt;
| H.263 || &amp;lt;tt&amp;gt;kH263CodecType&amp;lt;/tt&amp;gt; || &amp;quot;&amp;lt;tt&amp;gt;h263&amp;lt;/tt&amp;gt;&amp;quot; || This standard originally was designed for videoconferencing, yet is surprisingly good in a wide range of bitrates.&lt;br /&gt;
|-&lt;br /&gt;
| Pixlet || N/A || &amp;quot;&amp;lt;tt&amp;gt;pxlt&amp;lt;/tt&amp;gt;&amp;quot; || This wavelet-based codec, introduced in 2003, achieves high compression rates (20:1) without showing graphics artifacts like other codecs at similar compression levels. It requires powerful CPUs (PowerPC G4 or G5 at 1GHz and up) to decode.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As of this writing, Apple has demonstrated but not released an H.264 (aka AVC) codec for QuickTime. This is the newest and most powerful MPEG-4 codec, offering broadcast-quality video at 1.5 megabits per second (Mbps) and HDTV quality at 5-9Mbps, assuming your computer is powerful enough to decode it.&lt;br /&gt;
&lt;br /&gt;
Also, other than making these &amp;quot;Ken Burns Effects,&amp;quot; what am I going to do with writing video samples? This technique is the key to creating ''anything you want'' in a video track. Want to make a movie of your screen? Use the screen-grab lab from [[QuickTime for Java: A Developer's Notebook/Working with QuickDraw|Chapter 5]] and compress its &amp;lt;tt&amp;gt;GWorld&amp;lt;/tt&amp;gt; into a video track. Have some code to decode a format that QuickTime doesn't understand? Now you can transcode to any QuickTime-supported format. You even can take 3D images from an OpenGL or JOGL application and make them into movies.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
''Considering Chapter 5 showed how to grab the screen (even with the DVD Player running) into a GWorld, and considering you can make video tracks from any GWorld...uh-oh''.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</description>
			<pubDate>Thu, 06 Mar 2008 23:50:56 GMT</pubDate>			<dc:creator>Docbook2Wiki</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:QuickTime_for_Java:_A_Developer%27s_Notebook/Video_Media</comments>		</item>
	</channel>
</rss>