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

<channel>
	<title>Breaking Eggs And Making Omelettes &#187; Open Source Multimedia</title>
	<atom:link href="http://multimedia.cx/eggs/category/open-source-multimedia/feed/" rel="self" type="application/rss+xml" />
	<link>http://multimedia.cx/eggs</link>
	<description>Topics On Multimedia Technology and Reverse Engineering</description>
	<lastBuildDate>Thu, 26 Jan 2012 18:47:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>2011 In Open Source Multimedia</title>
		<link>http://multimedia.cx/eggs/2011-in-open-source-multimedia/</link>
		<comments>http://multimedia.cx/eggs/2011-in-open-source-multimedia/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 07:39:57 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=3683</guid>
		<description><![CDATA[A look back at what transpired in open source multimedia during the calendar year of 2011; highlights include the notorious project split]]></description>
			<content:encoded><![CDATA[<p>Sometimes I think that the pace of multimedia technology is slowing down. Obviously, I&#8217;m not paying close enough attention. I thought I would do a little 2011 year-end review of what happened in the world of open source multimedia, mainly for my own benefit. Let me know in the comments what I missed.</p>
<p><strong>The Split</strong><br />
The biggest deal in open source multimedia was the matter of the project split. Where once stood one project (<a href="http://ffmpeg.org/">FFmpeg</a>) there now stands two (also <a href="http://libav.org/">Libav</a>). Where do things stand with the projects now? Still very separate but similar. Both projects obsessively monitor each other&#8217;s git commits and prodigiously poach each other&#8217;s work, both projects being LGPL and all. Most features that land in one code base end up in the other. Thus, I refer to FFmpeg and Libav collectively as &#8220;the projects&#8221;.</p>
<p>Some philosophical reasons for the split included project stagnation and development process friction. Curiously, these problems are fond memories now and the spirit of competition has pushed development forward at a blinding pace.</p>
<p>People inside the project have strong opinions about the split; that&#8217;s understandable. <a href="http://phoronix.com/forums/showthread.php?37331-A-Group-Of-FFmpeg-Developers-Just-Forked-As-Libav">People outside the project</a> have <a href="http://news.ycombinator.com/item?id=2325806">strong opinions</a> about <a href="http://lwn.net/Articles/433347/">the split</a>; that&#8217;s somewhat less understandable, but whatever. After 5 years of working for Adobe on the Flash Player (a.k.a. the most hated software in all existence if internet nerds are to be believed on the matter), I&#8217;m <em>so over</em> internet nerd drama.</p>
<p>For my part, I just try to maintain some appearance of neutrality since I manage some shared resources for the open source multimedia community (like <a href="http://wiki.multimedia.cx/">the wiki</a> and <a href="http://samples.mplayerhq.hu/">samples repo</a>) and am trying to keep them from fracturing as well.</p>
<p><strong>Apple and Open Source</strong><br />
It was big news that <a href="http://multimedia.cx/eggs/alac-open-sourced/">Apple magnanimously open sourced their lossless audio codec</a>. That sets a great example and precedent.</p>
<p><strong>New Features</strong><br />
I mined the <code>'git log'</code> of the projects in order to pick out some features that were added during 2011.</p>
<p>First off, <a href="http://wiki.multimedia.cx/index.php?title=Apple_ProRes">Apple&#8217;s ProRes video codec</a> was reverse engineered and incorporated into the multimedia libraries. And for some weird reason, <em>this</em> is an item that made the rounds in the geek press. I&#8217;m not entirely sure why, but it may have something to do with inter-project conflict. Anyway, here is the decoder in action, playing a video of some wild swine, one of the few samples we have:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/01/apple-prores-boar-video.jpg" alt="" title="Apple ProRes screenshot -- the boar video" width="400" height="301" class="aligncenter size-full wp-image-3684" /><br />
</center></p>
<p>Other new video codecs included a reverse engineered <a href="http://wiki.multimedia.cx/index.php?title=Indeo_4">Indeo 4</a> decoder. Gotta catch &#8216;em all! That completes our collection of Indeo codecs. But that wasn&#8217;t enough&#8211; this year, we got a completely revised <a href="http://wiki.multimedia.cx/index.php?title=Indeo_3">Indeo 3</a> decoder (the previous one, while functional, exhibited a lot of code artifacts betraying a direct ASM -&gt;C translation). Oh, and many thanks to <a href="http://codecs.multimedia.cx/">Kostya</a> for this gem:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/01/wc4-trailer-screenshot.jpg" alt="" title="Wing Commander IV trailer playing with open source Xan codec" width="336" height="211" class="aligncenter size-full wp-image-3685" /><br />
</center></p>
<p>That&#8217;s the new <a href="http://wiki.multimedia.cx/index.php?title=Origin_Xan_Codec">Origin Xan decoder</a> (best known for <a href="http://www.mobygames.com/game/wing-commander-iv-the-price-of-freedom">Wing Commander IV</a> cinematics) in action, something I first started reverse engineering back in 2002. Thanks to Kostya for picking up my slack yet again.</p>
<p>Continuing with the codec section, <span id="more-3683"></span>there is a decoder for <a href="http://wiki.multimedia.cx/index.php?title=Flash_screen_video">Adobe Flash Screen Video 2</a> &#8212; big congrats on this! One of my jobs at Adobe was documenting this format to the outside world and I was afraid I could never quite make it clear enough to build a complete re-implementation. But the team came through.</p>
<p>Let&#8217;s see, there are decoders for <a href="http://wiki.multimedia.cx/index.php?title=VBLE">VBLE video</a>, <a href="http://wiki.multimedia.cx/index.php?title=Ut_Video">Ut Video</a>, <a href="http://wiki.multimedia.cx/index.php?title=VC-1">Windows Media Image</a> (WMVP/WMP2), <a href="http://wiki.multimedia.cx/index.php?title=Bink_Audio">Bink audio</a> version &#8216;b&#8217;, H.264 4:2:2 intra frames, and MxPEG video. There is a <a href="http://wiki.multimedia.cx/index.php?title=DPX_/_Cineon">DPX image</a> encoder, a <a href="http://wiki.multimedia.cx/index.php?title=Cirrus_Logic_AccuPak">Cirrus Logic AccuPak</a> video encoder, and a v410 codec.</p>
<p>How about some more game stuff? The projects saw &#8212; at long last &#8212; an <a href="http://wiki.multimedia.cx/index.php?title=SMJPEG">SMJPEG</a> demuxer. This will finally allow usage and testing of the SMJPEG IMA ADPCM audio decoder I added about a decade ago. Funny story behind that&#8211; I was porting all of my decoders from <a href="http://www.xine-project.org/home">xine</a> which included the SMJPEG ADPCM. I just never quite got around to writing a corresponding demuxer. Thanks to Paul Mahol for taking care of that.</p>
<p>Here&#8217;s a <a href="http://wiki.multimedia.cx/index.php?title=DFA">DFA</a> playback system for a 1995 DOS CD-ROM title called <a href="http://www.mobygames.com/game/dos/chronomaster">Chronomaster</a>. No format is too obscure, nor its encoded contents too cheesy:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/01/dfa-screenshot.jpg" alt="" title="Chronomaster DFA playback" width="400" height="321" class="aligncenter size-full wp-image-3686" /><br />
</center></p>
<p>There&#8217;s now a demuxer for a format called <a href="http://wiki.multimedia.cx/index.php?title=XMV">XMV</a> that was (is?) prevalent on Xbox titles. Now the projects can handle FMV files from many Xbox games, such as <a href="http://www.mobygames.com/game/xbox/thrillville">Thrillville</a>.</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/01/thrillville-xmv-screenshot.jpg" alt="" title="XMV from the Xbox game Thrillville" width="400" height="321" class="aligncenter size-full wp-image-3687" /><br />
</center></p>
<p>The projects also gained the ability to play BMV files. I think this surfing wizard comes from <a href="http://www.mobygames.com/game/discworld-ii-mortality-bytes">Discworld II</a>. It&#8217;s non-computer-generated animation at a strange resolution.</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2012/01/surfing-bmv-screenshot.jpg" alt="" title="BMV playback system: Surfing wizard" width="400" height="290" class="aligncenter size-full wp-image-3688" /><br />
</center></p>
<p>More demuxers: <a href="http://wiki.multimedia.cx/index.php?title=Microsoft_xWMA">xWMA</a>, PlayStation Portable PMP format, and <a href="http://wiki.multimedia.cx/index.php?title=CRI_ADX_ADPCM">CRI ADX format</a>; muxer for OpenMG audio and LATM muxer/demuxer.</p>
<p>One more thing: an <a href="http://en.wikipedia.org/wiki/Advanced_Vector_Extensions">AVX</a>-optimized fast Fourier transform (FFT). If you have a machine that supports AVX, there&#8217;s no way you&#8217;ll even notice the speed increase of a few measly FFT calls for audio coding/decoding, but that&#8217;s hardly the point. The projects always use everything on offer for any CPU.</p>
<p><em>Please make me aware of features that I missed in the list!</em></p>
<p><strong>Continuous Testing</strong><br />
As a result of the split, each project has its own FATE server, <a href="http://fate.ffmpeg.org/">one for FFmpeg</a> and <a href="http://fate.libav.org/">one for Libav</a>. As of the new year, FFmpeg has just over 1000 tests while Libav had 965. This is one area where I&#8217;m obviously ecstatic to see competition. Some ad-hoc measurements on my part indicate that the total code coverage via the FATEs has not appreciably increased. But that&#8217;s a total percentage. Both the test count and the code count have been steadily rising.</p>
<p><strong>Google Summer of Code and Google Code-In</strong><br />
Once again, the projects were allowed to participate in the Google Summer of Code as well as Google Code-In. I confess that I didn&#8217;t keep up with these too carefully (and Code-In is still in progress as of this writing). I do know that the project split occurred after FFmpeg had already been accepted for GSoC season 2011 and the admins were gracious enough to allow FFmpeg and Libav to allow both projects to participate in the same slot as long as they could both be mature about it. </p>
<p><strong>Happy New Year</strong><br />
Let&#8217;s see what we can accomplish in 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/2011-in-open-source-multimedia/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>FFmpeg 0.6; Something About HTML5</title>
		<link>http://multimedia.cx/eggs/ffmpeg-0-6-something-about-html5/</link>
		<comments>http://multimedia.cx/eggs/ffmpeg-0-6-something-about-html5/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 05:34:47 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2556</guid>
		<description><![CDATA[FFmpeg 0.6 is out and apparently has something to do wth HTML5]]></description>
			<content:encoded><![CDATA[<p><a href="http://ffmpeg.org/">The FFmpeg project</a> made a formal release yesterday. You can download version 0.6 from the <a href="http://ffmpeg.org/download.html">project&#8217;s download page</a>.</p>
<p>I&#8217;ve actually been seeing more news items about this today than I would have expected. This is most likely because the 0.6 release is named <em>&#8220;Works with HTML5&#8243;</em>. Let it never be said that nerds don&#8217;t know marketing. The team really latched on to the hottest buzzword going right now.</p>
<p>The name of the release refers to FFmpeg&#8217;s new native support for <a href="http://www.webmproject.org/">Google&#8217;s WebM format</a>. It can mux and demux the WebM container, and decode the Vorbis audio, all natively (FFmpeg&#8217;s Vorbis encoder has been demoted to &#8220;experimental&#8221; for this release and it is recommended to enable libvorbis for encoding). But the big news is that this release can support Google&#8217;s libvpx natively for VP8 encoding and decoding, without having to apply any other patches.</p>
<p>Getting libvpx to compile still might be a bit tricky. Fortunately, the <a href="http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2010-June/090751.html">first pass of a native, independent VP8 decoder</a> is currently in review on the ffmpeg-devel list.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/ffmpeg-0-6-something-about-html5/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Competition In Open Source</title>
		<link>http://multimedia.cx/eggs/competition-in-open-source/</link>
		<comments>http://multimedia.cx/eggs/competition-in-open-source/#comments</comments>
		<pubDate>Wed, 19 May 2010 00:54:49 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2479</guid>
		<description><![CDATA[Could we use some more competition in the open source multimedia arena?]]></description>
			<content:encoded><![CDATA[<p>At the recent <a href="http://events.linuxfoundation.org/events/collaboration-summit">Linux Foundation Collaboration Summit</a>, I was chatting with someone heavily involved in a major open source SQL database program. I asked how he feels about the interminable hype surrounding so-called <a href="http://en.wikipedia.org/wiki/NoSQL">NoSQL databases</a>. Among other sentiments, he mentioned that he felt positive regarding the fact that there is competition in the open source database arena once more which is driving much innovation.</p>
<p>Of course, I have to frame everything through my multimedia lense and I pondered the notion of competition in open source multimedia development. Some of my fondest memories of open source development come from 2002-2003 when the <a href="http://www.xine-project.org/">xine</a> and <a href="http://www.mplayerhq.hu/">MPlayer</a> teams were engaged in open war, trying to create the best open source multimedia player. The competition was a major factor.</p>
<p>These days, the deepest multimedia development occurs on the <a href="http://ffmpeg.org/">FFmpeg</a> project. FFmpeg is pretty much a category-killer. There&#8217;s nothing else like it in the open source or proprietary worlds (and if you think you know of a competitor, it&#8217;s probably using FFmpeg as its backend). Would things move faster if there were serious competitors to FFmpeg?</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/competition-in-open-source/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Kega Video In FFmpeg</title>
		<link>http://multimedia.cx/eggs/kega-video-in-ffmpeg/</link>
		<comments>http://multimedia.cx/eggs/kega-video-in-ffmpeg/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 17:37:54 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Game Hacking]]></category>
		<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2364</guid>
		<description><![CDATA[FFmpeg supports another (tangentially) game-related video codec]]></description>
			<content:encoded><![CDATA[<p>Thanks to Daniel Verkamp for contributing a Kega video (KGV1) decoder to <a href="http://ffmpeg.org/">FFmpeg</a>. I was about to demand samples for testing until I looked up what Kega is &#8212; a Sega game console emulator &#8212; when I realized that it would be more fun to create my own (be advised that only the Windows version of <a href="http://www.eidolons-inn.net/tiki-index.php?page=kega">Kega</a> presently supports the AVI encoding option). Then I looked up the <a href="http://wiki.multimedia.cx/index.php?title=Kega_Video">Wiki page</a> and realized that there is, in fact, one sample on record at the archive. Well, I went ahead and made my own sample anyway. I used the mountainside attract-mode scene from the Genesis game <a href="http://www.mobygames.com/game/genesis/strider">Strider</a>, one of my favorite sequences in any video game. It&#8217;s in <a href="http://samples.mplayerhq.hu/V-codecs/kgv1/">the samples directory</a>.</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2010/04/strider-mountain-attract.jpg" alt="" title="FFplay playing KGV1 video from Strider" width="400" height="342" class="aligncenter size-full wp-image-2365" /><br />
</center></p>
<p>I am holding off on adding a <a href="http://fate.multimedia.cx/">FATE</a> test; there&#8217;s still an endian issue (PPC configs disagree with x86 configs). I&#8217;m also a little puzzled as to why FFplay insists on playing the video as 320&#215;240 even though the video is encoded as 640&#215;480. For that matter, I&#8217;m also bewildered trying to understand why Kega renders video as 640&#215;480 by default; that&#8217;s not a native resolution for any of its emulated consoles.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/kega-video-in-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>On Open Sourcing On2</title>
		<link>http://multimedia.cx/eggs/on-open-sourcing-on2/</link>
		<comments>http://multimedia.cx/eggs/on-open-sourcing-on2/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 15:37:57 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[On2/Duck]]></category>
		<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2273</guid>
		<description><![CDATA[Let's seriously consider the possibility of Google open sourcing On2 video codecs]]></description>
			<content:encoded><![CDATA[<p>I have been reading way too many statements from people who confidently assert that Google will open source all of On2&#8242;s IP based on no more evidence than&#8230; the fact that they <em>really, really</em> hope it happens. Meanwhile, I have found myself pettily hoping it doesn&#8217;t happen simply due to the knowledge that <a href="http://www.fsf.org/blogs/community/google-free-on2-vp8-for-youtube/">the FSF will claim total credit</a> for such a development (don&#8217;t believe me? They already <a href="http://www.fsf.org/news/ibad_launch">claim credit for Apple dropping DRM from music purchases</a>: &#8220;Our Defective by Design campaign has a successful history of targeting Apple over its DRM policies&#8230; and under the pressure Steve Jobs dropped DRM on music.&#8221;)</p>
<p>But for the sake of discussion, let&#8217;s run with the idea: Let&#8217;s assume that Google open sources any of On2&#8242;s intellectual property. Be advised that if you&#8217;re the type who believes that all engineering problems large and small can be solved by applying, not thought, but a mystical, nebulous force called &#8220;open source&#8221;, you can go ahead and skip this post.</p>
<p><strong>The Stack</strong></p>
<p><span id="more-2273"></span></p>
<p>I like thinking about specific multimedia problems on this blog because people who read this blog often know beans about multimedia technology and are equipped to think about the issues involved. So imagine that Google open sources On2&#8242;s video codecs. What does that mean? <strong>Free web video for all!</strong> Well, not so fast. There are a few issues to consider. While most observers can only see as far as the video codec portion, there are, at the very least, 3 things to consider when putting together a video for consumption:</p>
<ol>
<li>Video codec &#8212; how are the pictures compressed and encoded?</li>
<li>Audio codec &#8212; presumably, you want some sound to go along with those moving pictures</li>
<li>Container format &#8212; there has to be a method for tying together audio and video for delivery and playback</li>
</ol>
<p>So, Google open sourcing On2&#8242;s video codecs would address the first need. What about the second need? Obviously, MP3 and AAC &#8212; which represent the standards today &#8212; would just get the open video argument back to square one. <strong>&#8220;VORBIS!!!&#8221;</strong> would be the reflexive cry of the open source checklister crowd. Indeed, this just might work. Vorbis has problems and shortcomings but is generally considered a reasonable replacement for MP3, WMA, and AAC, at least for desktop computing applications (we&#8217;ll think outside of the desktop arena a little later). Actually, there is another option: Did you know that On2 dabbled in audio codecs at one time? They developed 2 <a href="http://wiki.multimedia.cx/index.php?title=IMA_ADPCM">IMA ADPCM</a> variants (<a href="http://wiki.multimedia.cx/index.php?title=Duck_DK4_IMA_ADPCM">DK4</a> and <a href="http://wiki.multimedia.cx/index.php?title=Duck_DK3_IMA_ADPCM">DK3</a>) which wouldn&#8217;t be seriously considered for this application. They also have something they simply called <a href="http://wiki.multimedia.cx/index.php?title=On2_Audio_for_Video_Codec">Audio for Video Codec</a> (inspired). I know we have samples of the latter somewhere.</p>
<p>How about the last component on the list, the container format? How about Ogg? Ogg is not usually considered a general-purpose container format. It would require extension to be capable of storing any new codec (I argue that a container is not general-purpose if a demuxer has to have special code to handle every codec that could possibly be inside, which is pretty much how Ogg works). The prevailing container format on the standard MPEG side is the QuickTime-derived MP4 format. This could hold new On2 data (and probably does so in various applications today), but I&#8217;m not sure about encoding Vorbis data.</p>
<p>This is the part of the post where I learned something new (which is a big reason I like writing these blog posts). My theory was that there was no agreed-upon method for storing Vorbis audio data in QuickTime/MP4. But if there were something resembling a standard on this front, FFmpeg would implement it. So I tried transcoding an audio file to a Vorbis encoded .MOV or .MP4 and not only did both take, both played back in FFplay.</p>
<p><strong>Mobile Considerations</strong></p>
<p>Okay, so the MP4/VPn/Vorbis stack might just be crazy enough to work&#8230; <em>in the desktop realm</em>. There&#8217;s the emerging world out there collectively called &#8220;mobile&#8221; &#8212; cell phones, netbooks, tablet computers, and more &#8212; and they all want to be able to show video. They often do this with dedicated processors that are designed to decode the standard MPEG codecs (H.264 and AAC). I&#8217;ve read from various observers who wave away this problem of decoding a new stack on mobile by invoking 3 magic letters: &#8216;DSP&#8217;. This is a good example of how a little knowledge can be dangerous. There seems to be a general misconception that DSPs (digital signal processors) are extraordinary devices that can be programmed to accelerate the decoding of any video or audio codec. The reality isn&#8217;t so simple.</p>
<p>I confess, I don&#8217;t know to what extent today&#8217;s generation of mobile devices employ general-purpose, programmable DSPs vs. custom MPEG ASICs but that would make for an interesting survey. While I&#8217;m confident that any device in the &#8220;mobile&#8221; category could likely be programmed to play data encoded in the MP4/VPn/Vorbis stack, the issue then becomes battery usage&#8211; how long can the custom programmed system play video vs. how long could the same unit play by pushing MPEG data through the custom ASICs? Again, don&#8217;t know, but it would be interesting to find some numbers or develop experiments to test this.</p>
<p><strong>The Google/YouTube Factor</strong></p>
<p>Observers obsess about the Google/YouTube angle in all this, which is understandable due to the large mindshare that YouTube controls when it comes to web video. &#8220;Control the YouTube video format, control the future of the internet,&#8221; or so the popular sentiment seems to go (be advised, however, that <a href="http://www.reelseo.com/long-tail-time-spent-video/">YouTube doesn&#8217;t necessarily represent as much online video viewing as you might think</a>). One received bit of wisdom is that Google already stores multiple copies of every video in various formats, so one more shouldn&#8217;t be any big burden. Our thoughts are not Google&#8217;s thoughts, neither are Google&#8217;s ways our ways (I&#8217;m sure I read that somewhere). It&#8217;s hard to know exactly how YouTube operates, but we can always <a href="http://multimedia.cx/eggs/poking-at-youtube/">poke at it to find clues</a>. Outside of Google, few people are as interested in YouTube&#8217;s operation as <a href="http://x264dev.multimedia.cx/">Dark Shikari</a> of x264 fame and <a href="http://news.ycombinator.com/item?id=1138476">here are some interesting tidbits he has empirically determined</a>. Of interest to this discussion is the following: &#8220;They could have saved 30-50% on bandwidth by offering an H.264 High stream for PC viewers, but they <em>didn&#8217;t</em> because it would have required they keep around a separate stream.&#8221; This indicates that Google doesn&#8217;t necessarily consider disk space to be limitless, at least not in the disk space vs. bandwidth trade-off calculation. I know for a fact that YouTube also keeps around the original copies of all the videos that have ever been uploaded (because certain videos that were not transcoded properly years ago are now correct). However, YouTube only needs to keep one copy of the original around (and maybe a backup somewhere) while transcoded videos need to be shipped off to any number of content distribution nodes.</p>
<p>This doesn&#8217;t rule out the possibility that Google could push an MP4/VPn/Vorbis stack as the new web video standard and maintain parallel MPEG &#038; open copies of each YouTube video. But it&#8217;s not a foregone conclusion that it would be a drop in the bucket for Google&#8217;s resources. As a <a href="http://blogs.adobe.com/penguin.swf/">programmer for a large technology company</a>, I endure more than my fair share of outside advice regarding what my company ought to do for the benefit of everyone else except the company. I can only imagine how frustrating it must be for Google people to constantly read declarations along the lines of, &#8220;Google needs to spend untold millions of its own money in order to do what <em>I</em> believe is right,&#8221; especially considering that whole &#8220;don&#8217;t be evil&#8221; charter/moral bludgeon.</p>
<p><strong>In Closing</strong></p>
<p>Anyway, I just wanted to think about these issues from a purely technical standpoint, a perspective that I really don&#8217;t see discussed anywhere else (except when I read <a href="http://news.ycombinator.com/threads?id=DarkShikari">Dark Shikari try to talk sense</a> into online forums where video discussions abound). I don&#8217;t have all the facts but I enjoy not only searching for them, but also figuring out <em>how</em> to search for them.</p>
<p>Check out Silvia Pfeiffer&#8217;s recent blog post: <a href="http://blog.gingertech.net/2010/02/20/googles-challenges-of-freeing-vp8/">Google&#8217;s challenges of freeing VP8</a>. In addition to wondering about some of the same technical issues I have outlined here, she addresses the tough legal and patent issues surrounding a possible open sourcing. And none of this even begins to address the political and social issues surrounding the adoption of such a standard.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/on-open-sourcing-on2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Bink Video in FFmpeg</title>
		<link>http://multimedia.cx/eggs/bink-video-in-ffmpeg/</link>
		<comments>http://multimedia.cx/eggs/bink-video-in-ffmpeg/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 05:43:51 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[FATE Server]]></category>
		<category><![CDATA[Game Hacking]]></category>
		<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2265</guid>
		<description><![CDATA[Bink video is in FFmpeg, courtesy of Kostya]]></description>
			<content:encoded><![CDATA[<p>Today was the day: <a href="http://codecs.multimedia.cx/">Kostya</a> committed his <a href="http://twitter.com/ffmpegsvn/status/9428996080">Bink video decoder</a> to <a href="http://ffmpeg.org/">FFmpeg</a>. Here&#8217;s just one little screenshot:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2010/02/indiana-jones-bink.jpg" alt="Screenshot of the attract mode Bink video from Indiana Jones and the Emperor&#039;s Tomb" title="Screenshot of the attract mode Bink video from Indiana Jones and the Emperor&#039;s Tomb" width="400" height="323" class="aligncenter size-full wp-image-2266" /><br />
</center></p>
<p>Of course, this is just one Bink file out of the literal <em>thousands</em> of <a href="http://www.radgametools.com/binkgames.htm">software titles that have incorporated Bink video</a> (the above comes from <a href="http://www.mobygames.com/game/windows/indiana-jones-and-the-emperors-tomb">Indiana Jones and the Emperor&#8217;s Tomb for Windows</a>). For this reason, it&#8217;s entirely possible that the Bink video decoder (not to mention the Bink audio decoder and the Bink file format demuxer) might not cover all the cases out there. This is especially relevant considering intel I have received from a guy who has talked to the guy who invented Bink and described the development process. The upshot is that there could conceivably be a lot of custom Bink versions out there. That&#8217;s why Kostya hopes for a lot of testing with as many different Bink files that people can throw at this system. To that end, I started with my old <a href="http://multimedia.cx/mmjournal.html">Multimedia Exploration Journal</a> and did a text search for every game that I recorded as using Bink.</p>
<p>Just think: The next time that YouTube and assorted other video uploading services update their video conversion backends, they can finally be flooded with Bink videos. (I know it seems silly, but I sometimes feel like my biggest contribution to open source multimedia has been to allow people to upload to YouTube <a href="http://wiki.multimedia.cx/index.php?title=Sega_FILM">video files that they found</a> on <a href="http://wiki.multimedia.cx/index.php?title=Duck_TrueMotion_1">their old Sega Saturn CD-ROMs</a>).</p>
<p>As for <a href="http://fate.multimedia.cx/">FATE</a>, is it plausible to get a basic decoding test staged at this point? I ran a simple sample through my RPC testing tool and learned that the video output is bit exact across platforms. <a href="http://fate.multimedia.cx/index.php?test_spec=389">Test staged</a>.</p>
<p>(Aside: Thanks to Vitor Sessak, Valgrinder extraordinaire, for locating a memory bug in the Musepack v7 demuxer. Since I created and staged a v7 sample at the same time I staged a sample for the Musepack v8 demuxer, I have already activated a <a href="http://fate.multimedia.cx/index.php?test_spec=378">Musepack v7 demuxing test</a>.)</p>
<p>Here&#8217;s a project for someone that likes text processing and searching puzzles: Find a simple, efficient method for comparing my list of DOS/Windows games (<a href="http://spreadsheets.google.com/pub?key=to5QWBtAeTjKU3BERE-hIvg&#038;gid=0">here&#8217;s the HTML list</a> and <a href="http://spreadsheets.google.com/pub?key=to5QWBtAeTjKU3BERE-hIvg&#038;gid=0&#038;output=csv">here it is in CSV</a>) against the <a href="http://www.radgametools.com/binkgames.htm">big list of known Bink titles</a> and find all the Bink games in my PC game collection. I have already harvested samples from: Alien vs. Predator Gold Edition, Disney&#8217;s Atlantis, Gabriel Knight 3, Gods &#038; Generals, Halo 3 (Xbox 360), In Cold Blood, Indiana Jones and the Emperor&#8217;s Tomb, Monsters Inc. Wreck Room Arcade, Starlancer, Tony Hawk Pro Skater 2, Uru: Ages Beyond Myst. </p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/bink-video-in-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>WMA Voice in FFmpeg</title>
		<link>http://multimedia.cx/eggs/wma-voice-in-ffmpeg/</link>
		<comments>http://multimedia.cx/eggs/wma-voice-in-ffmpeg/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 05:04:26 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2223</guid>
		<description><![CDATA[FFmpeg now features a WMA Voice decoder]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.gnome.org/rbultje/">Ronald Bultje</a> has been a long-time contributor to a variety of open source multimedia projects. He was keen to try his hand at reverse engineering and implementing an <a href="http://wiki.multimedia.cx/index.php?title=Category:Undiscovered_Codecs">undiscovered codec</a>. Most people start simple, but Ronald went for a <a href="http://wiki.multimedia.cx/index.php?title=Category:Vocoders">vocoder</a> (significantly more complex than the piddly little ADPCM codecs I started with). He has completed his reverse engineering of the <a href="http://wiki.multimedia.cx/index.php?title=Windows_Media_Audio_Voice">Windows Media Audio 9 Voice</a> algorithm and <a href="http://twitter.com/ffmpegsvn/status/9010281328">committed a decoder</a> for <a href="http://ffmpeg.org/">FFmpeg</a>. If you&#8217;re interested in the technical details, check out Ronald&#8217;s blog posts on the matter: <a href="http://blogs.gnome.org/rbultje/2009/12/31/codec-woes/">Codec Woes</a> and <a href="http://blogs.gnome.org/rbultje/2010/01/25/wmavoice-codec-dissection/">WMA Voice Codec Dissection</a>.</p>
<p>Here is a WMA Voice file being played in FFplay using <a href="http://guru.multimedia.cx/">Michael&#8217;s</a> spectrum visualization (now the default audio visualization):</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2010/02/ffplay-spectrum-wma-voice.jpg" alt="FFplay&#039;s spectrum analyzer playing a WMA Voice file" title="FFplay&#039;s spectrum analyzer playing a WMA Voice file" width="400" height="323" class="aligncenter size-full wp-image-2224" /><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/wma-voice-in-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autostreamable FFmpeg</title>
		<link>http://multimedia.cx/eggs/autostreamable-ffmpeg/</link>
		<comments>http://multimedia.cx/eggs/autostreamable-ffmpeg/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 02:06:50 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2070</guid>
		<description><![CDATA[qt-faststart is good but could conceivably be better (or go away completely)]]></description>
			<content:encoded><![CDATA[<p>We have a solution to the problem of making <a href="http://wiki.multimedia.cx/index.php?title=QuickTime_container">QuickTime/MP4 files</a> streamable. It&#8217;s called qt-faststart. The solution has problems which we have tried to remedy over the years. Recently, I proposed another patch to another problem. But can we obviate the need for qt-faststart entirely in favor of a more integrated solution? <em>Is that even a good idea?</em></p>
<p>Every so often, the <a href="http://ffmpeg.org/">FFmpeg project</a> receives a bug report about qt-faststart operating incorrectly&#8211; it would mysteriously no-op and output a blank file. Each time, we have to dredge up our recollections of what causes this and how to fix it. Turns out that the problem is always caused by users manually compiling the utility (&#8216;gcc qt-faststart.c -o qt-faststart&#8217;) which will produce incorrect operation on 64-bit platforms. The solution is to build it with FFmpeg&#8217;s build system (after running &#8216;./configure&#8217;, run &#8216;make tools/qt-faststart&#8217;). I even wrote that down in the header comments of qt-faststart.c.</p>
<p>Then I smacked myself hard for expecting average end users to actually read <em>source code comments</em>. It&#8217;s bad enough that they have to compile a program in the first place. For the average user, it&#8217;s laudable that they figured out enough to run &#8216;gcc&#8217; manually. When the compiler didn&#8217;t complain, that&#8217;s reason for optimism.</p>
<p>I decided to modify qt-faststart.c so that it fails to compile via a simple gcc build command while printing out a helpful error message. Then I got to pondering the classic problem of muxing a streamable QT/MP4 file in the first place. Here&#8217;s what I&#8217;m thinking:</p>
<p><strong>Estimating Header Space</strong><br />
<em>If</em> the duration of an input file is known at the outset, it should be reasonable to estimate how much space the moov header will need. Develop a formula based on the input file&#8217;s duration, video output frames per second, and target audio codec characteristics, and decide how much space to set aside. The more frames there will be in the target file, the more header bytes will need to be set aside for entries in the various sample tables. At this phase, calculate the amount of space to set aside for all <a href="http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/">specified metadata</a>. Add a little space to the computed header size for good measure, create a new file, and jump straight ahead to the position indicated by that size to start writing the mdat atom. After the mdat atom has been laid down, write down the moov atom plus a free space atom to make up any size difference.</p>
<p><strong>Naive Fallback</strong><br />
If the input format does not specify its total duration (perhaps a live source or it might be from any of a number of file formats for which there is simply no efficient way to compute duration without decoding the whole file), then the whole of qt-faststart could be effectively integrated into the QT/MP4 muxer as a post-processing phase.</p>
<p><strong>Is This A Good Idea?</strong><br />
I get the impression that FFmpeg is a major player in the world of video conversion. Further, QT/MP4 is pretty much <a href="http://multimedia.cx/eggs/the-standard-like-it-or-not/">the ubiquitous standard</a> these days. I worry about changing a fundamental bit of the way the biggest tool creates QT/MP4 files. There must be many toolchains and installations out there which already perform the &#8220;mux; qt-faststart&#8221; sequence. Will changing this behavior hurt anything? qt-faststart doesn&#8217;t do anything to a file that is already streamble; it doesn&#8217;t even create a blank file. So modifying FFmpeg to directly create streamable QT/MP4 files will break programs that expect to run &#8216;FFmpeg &#038;&#038; qt-faststart&#8217;.</p>
<p>One alternative would be to add streamable remuxing as another command line option. But that somewhat ruins the user-friendliess aspect of creating the desired streamable files per the default mode of operation.</p>
<p>I don&#8217;t have any answers right now and certainly no time to code a prototype (nor inclination, unless I&#8217;m darn sure the idea would be accepted into the codebase).</p>
<p><strong>See Also:</strong></p>
<ul>
<li><a href="http://multimedia.cx/eggs/improving-qt-faststart/">Improving qt-faststart</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/autostreamable-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installing CrystalHD Drivers In Linux</title>
		<link>http://multimedia.cx/eggs/installing-crystalhd-drivers-in-linux/</link>
		<comments>http://multimedia.cx/eggs/installing-crystalhd-drivers-in-linux/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 05:46:01 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2057</guid>
		<description><![CDATA[A chronicle of my effort to get a CrystalHD chip working in Linux]]></description>
			<content:encoded><![CDATA[<p><strong>Executive Summary:</strong> I tried to get a Broadcom CrystalHD chip to work in Linux. I came close to being successful. The chip, kernel driver, and userspace library all work. The example app that would have been the payoff&#8230; not so much. I document my process in this post in case others need assistance, or can lend assistance in the final step.</p>
<p>There was <a href="http://xbmc.org/davilla/2009/12/29/broadcom-crystal-hd-its-magic/">some news recently about Broadcom open sourcing code related to a video decoding chip</a>. The brand name here is apparently &#8220;CrystalHD&#8221; and the chip in question is the BCM-70012. I came into possession of one of these and endeavored to make the open source software surrounding it work in Linux.</p>
<p>The first issue is installing the hardware. It&#8217;s a PCI Express mini card which has the same form factor as a PCIe mini wireless networking card. So if your computer can host such a wireless card, it can also hold this thing. <em>Allegedly</em>. First, I tried to place it in the empty PCIe-mini slot in my MSI Wind Nettop. No go. The machine refused to boot up (it would power up but never beep to indicate that it&#8217;s really ready to run). Removing the card made the problem go away.</p>
<p>So determined was I to make this chip work that I actually took apart my dear Eee PC 701, ripped out the wireless card and replaced it with the Broadcom card. Deciding it would be too much trouble to attempt to re-attach the keyboard and touchpad ribbons, I realized I could just use USB peripherals.</p>
<p>Resigned to the notion that I just foolishly destroyed my 2 year old Eee PC, I threw the switch anyway and was quite surprised to see it boot up normally. An &#8216;lspci&#8217; command indicates a new Broadcom multimedia controller hanging off the PCI bus. It&#8217;s not pretty but it&#8217;s breathing:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2010/01/eee-pc-701-broadcom-crystalhd.JPG" alt="Eee PC 701 disassembled with Broadcom CrystalHD decoder installed" title="Eee PC 701 disassembled with Broadcom CrystalHD decoder installed" width="400" height="457" class="aligncenter size-full wp-image-2058" /><br />
</center></p>
<p>So let&#8217;s talk software. Broadcom released the driver as open source. To many in the open source community, this is tantamount to, &#8220;Okay, done deal! What else needs to be open sourced?&#8221; Not so fast. There&#8217;s no documentation in the whole package (user-wise, anyway; the libcrystalhd API is thoroughly documented in header comments). So I will describe my experiences with the software.</p>
<p><span id="more-2057"></span></p>
<p><a href="http://www.broadcom.com/support/crystal_hd/">Download the Linux driver package and unpack it.</a></p>
<p>Have some kernel source to build against. You don&#8217;t actually need a full source tree installed; just the headers will do. To install the appropriate header package on an Ubuntu system, execute:</p>
<pre>
  apt-get install linux-headers-`uname -r`
</pre>
<p>When installing a linux-headers package, it&#8217;s necessary to specify a kernel version. `uname -r` will determine your Linux kernel version and substitute it into the command line.</p>
<p>If you&#8217;re going the route of installing only kernel headers like I did, you will also need to create a symlink from /lib/modules/&lt;version&gt;/build to the new headers tree. This should do the trick:</p>
<pre>
  ln -s /usr/src/linux-headers-`uname -r` /lib/modules/`uname -r`/build
</pre>
<p>With that infrastructure in place, change directory into crystalhd/driver/linux. <strong>Important step:</strong> Run &#8216;dos2unix *&#8217; in this directory. There are DOS-style line endings running around in here that will foul up the build process. Run &#8216;autoconf&#8217;. Then run &#8216;./configure&#8217;. The whole process looks sort of like this:</p>
<pre>
$ dos2unix *
$ autoconf
$ ./configure
checking for ld... ld
configure: creating ./config.status
config.status: creating ./Makefile
</pre>
<p>Time to build: &#8216;make&#8217;. This should look something like:</p>
<pre>
$ make
make -C /lib/modules/2.6.30.5-ep0/build SUBDIRS=/home/melanson/crystalhd/driver/linux modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.30.5-ep0'
  CC [M]  /home/melanson/crystalhd/driver/linux/crystalhd_lnx.o
  CC [M]  /home/melanson/crystalhd/driver/linux/crystalhd_misc.o
  CC [M]  /home/melanson/crystalhd/driver/linux/crystalhd_cmds.o
  CC [M]  /home/melanson/crystalhd/driver/linux/crystalhd_hw.o
  LD [M]  /home/melanson/crystalhd/driver/linux/crystalhd.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/melanson/crystalhd/driver/linux/crystalhd.mod.o
  LD [M]  /home/melanson/crystalhd/driver/linux/crystalhd.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.30.5-ep0'
</pre>
<p>&#8216;make install&#8217; (as root, of course) to get the module where it needs to go and then &#8216;modprobe crystalhd&#8217; to activate the driver. After the modprobe command, the last line of my &#8216;dmesg&#8217; log looks like:</p>
<pre>
  Broadcom 70012 Decoder 0000:01:00.0: setting latency timer to 64
</pre>
<p>We&#8217;re not done yet, though. There are 2 provided scripts (bcm_70012_???.sh) which are supposed to load the module and create a device node. The scripts failed to run. Instead, I sorted out the right command for my machine:</p>
<pre>
mknod -m 666 /dev/crystalhd c 251 0
</pre>
<p>The major number (251) comes from &#8216;grep crystalhd /proc/devices&#8217;.</p>
<p>Then we move over to the user-land system library (crystalhd/linux_lib/libcrystalhd). A simple &#8216;make &#038;&#038; sudo make install&#8217; should do the trick here.</p>
<p>Then there&#8217;s the matter of the example code (crystalhd/examples). Whoever wrote these samples was not in close communication with the people who wrote the rest of the library. It&#8217;s reasonable that the code did work at some point. But whoever made this final package reorganized the directory structure and didn&#8217;t test this code since there are all kinds of problems when running the simple build script included.</p>
<p>Things went off the rails at this point.</p>
<p>The build script doesn&#8217;t build as-is due to incorrect paths. I changed the build script to look like this:</p>
<p>g++ -I ../include/ -I ../linux_lib/libcrystalhd/ -I/usr/include -D__LINUX_USER__ -lcrystalhd -lpthread hellobcm.cpp -o hellobcm</p>
<p>This is to be run from the examples directory. Doing so, however, indicates that hellobcm.cpp has several problems. Upshot: I altered the start of the file to look like this (added 2 headers, subtracted one, added U8 and U32 typedefs which might only work on x86_32):</p>
<pre>
#include &lt;stdlib .h&gt;
#include &lt;stdio .h&gt;
#include &lt;stdint .h&gt;
#include &lt;string .h&gt;
#include &lt;semaphore .h&gt;
#include "bc_dts_types.h"
#include "bc_dts_defs.h"
#include "libcrystalhd_if.h"
//#include "bc_ldil_if.h"
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;sys /shm.h&gt;

typedef unsigned char U8;
typedef unsigned int U32;

#define TRY_CALL_1(func, p1, errmsg) \
[...]
</pre>
<p>That gets the test program to compile. Running it results in a complaint that firmware can&#8217;t be located in a preordained location:</p>
<pre>
[...]
DtsGetFirmwareFiles:Ctx->FwBinFile is /lib/firmware/bcmFilePlayFw.bin
Failed to Open FW file
[...]
</pre>
<p>All right, so it wants the firmware files in very specific places (this is actually due to that libcrystalhd user-land library). These firmware files live in crystalhd/firmware/fwbin/70012. Moving the firmware files to /lib/firmware (hey! there are a bunch of firmware files there; I never knew that), makes hellobcm get farther before tossing out a cryptic error. A little investigation reveals that the source is looking for a hardcoded .264 video file (home directory paths implicate a &#8216;jarod&#8217; and a &#8216;davilla&#8217;, perhaps the same davilla who <a href="http://xbmc.org/davilla/2009/12/29/broadcom-crystal-hd-its-magic/">authored the XBMC blog post</a>).</p>
<p>So I need to feed it a raw .264 video file. All right, Broadcom, let&#8217;s see what you&#8217;ve got. Chew on the <a href="http://fate.multimedia.cx/index.php?test_spec=200">MV1_BRCM_1 H.264 sample</a> (<a href="http://samples.mplayerhq.hu/fate-suite/h264-conformance/">src19td.IBP.264 from here</a>), one of the meanest conformance samples in the ITU suite. Incidentally, it&#8217;s from Broadcom (hence, &#8220;BRCM&#8221;).</p>
<p>Things go&#8230; well, confusingly. The program emits a lot of debugging info which largely emanates from the libcrystalhd.so library (that&#8217;s also the code which downloads the firmware at initialization). I&#8217;m still massaging the code (various other parameters seem to be hardcoded based on the sample) but when it does run successfully, it claims to decode 136/257 frames from the sample. And it does so while occupying the CPU for about a quarter of a second.</p>
<p>For comparison, it takes <a href="http://ffmpeg.org/">FFmpeg</a> 16.6 seconds of CPU time to decode this sample using the following command line:</p>
<pre>
  ffmpeg -benchmark -i src19td.IBP.264 -f yuv4mpegpipe -y /dev/null
</pre>
<p>It is, of course, inappropriate to make comparisons before I can validate that this example is decoding anything correctly (and it&#8217;s a specious comparison anyway). It should be noted that 16.6s amounts to &#8220;less than realtime&#8221; for a sample that&#8217;s 10 seconds long. So that&#8217;s the time to beat on my Eee PC 701 equipped with an Intel Celeron M CPU running at 620 MHz&#8230; wait, no, <strong>ACK!</strong> /proc/cpuinfo reports the full 900 MHz! I accidentally overclocked the thing. Or rather, de-underclocked it. Oops. Per my understanding, the only negative implication of that is less battery time.</p>
<p>This same CrystalHD code seems to have been copy and pasted for <a href="http://code.google.com/p/crystalhd-for-osx/">crystalhd-for-osx</a>. The same example programs live in that tree. I doubt they compile.</p>
<p>Would CrystalHD driver support be useful for FFmpeg? It doesn&#8217;t really seem like a good fit. But then, FFmpeg already supports other hardware decoding features such as XvMC and VDPAU.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/installing-crystalhd-drivers-in-linux/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Supplying FFmpeg With Metadata</title>
		<link>http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/</link>
		<comments>http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 04:34:55 +0000</pubDate>
		<dc:creator>Multimedia Mike</dc:creator>
				<category><![CDATA[Open Source Multimedia]]></category>

		<guid isPermaLink="false">http://multimedia.cx/eggs/?p=2028</guid>
		<description><![CDATA[Explicitly documenting FFmpeg's metadata facilities]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE, 2010-06-17: This information is now maintained via the <a href="http://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata">FFmpeg Metadata page on the MultimediaWiki</a>.</strong></p>
<p>While creating <a href="http://multimedia.cx/eggs/archivists-burden/">my automated game archiving solution</a>, I wanted to automatically tag ALAC/M4A files with appropriate metadata while encoding using <a href="http://ffmpeg.org/">FFmpeg</a>. Then I realized I didn&#8217;t know how to do that. I do remember that FFmpeg recently supplanted a series of specific metadata command line options (like -title and -album) with a highly generalized metadata framework that is accessed by the option &#8216;-metadata &lt;key&gt;=&lt;value&gt;&#8217;. <a href="http://ffmpeg.org/ffmpeg-doc.html#SEC8">The official documentation</a> provides this lonely (and, I came to realize, useless NO-OP; more on why later) example of the option&#8217;s usage:</p>
<pre>
    `-metadata key=value'

      Set a metadata key/value pair. For example,
      for setting the title in the output file:

      ffmpeg -i in.avi -metadata title="my title" out.flv
</pre>
<p>So this option allows you to specify absolutely any key/value metadata pair you can imagine. However, a specific muxer won&#8217;t necessarily recognize it. How can I know the specific keys that, e.g., the MOV/MP4 muxer honors? 2 methods spring to mind: Trial and error (worked out well for me at first) and reading the code (which was made a good deal easier when I already knew a few of the keys that worked).</p>
<p>I think it would be a good idea to document the specific metadata keys that each muxer in FFmpeg recognizes. This blog post will lead by example. This data comes from SVN revision 20910, current as of 2009-12-21.</p>
<p><strong>QuickTime/MOV/MP4/M4A/et al.</strong></p>
<p>I have constructed the following table of the metadata keys that libavformat/movenc.c honors. The low-level identifier column lists the atom name that the format uses to encode the data on disc, which is not interesting to most readers. For the interested but uninitiated, the notation, e.g., &#8216;\251nam&#8217; indicates a 4-byte code consisting of the byte A9 in hexadecimal (or 251 in octal) followed by the ASCII characters &#8216;n&#8217;, &#8216;a&#8217;, and &#8216;m&#8217;.</p>
<p><span id="more-2028"></span></p>
<table border="1" cellpadding="5">
<tr>
<th>Key</th>
<th>iTunes field</th>
<th>Low-level identifier</th>
</tr>
<tr>
<td>&#8220;title&#8221;</td>
<td>Name</td>
<td>&#8216;\251nam&#8217;</td>
</tr>
<tr>
<td>&#8220;author&#8221;</td>
<td>Artist</td>
<td>&#8216;\251ART&#8217;</td>
</tr>
<tr>
<td>&#8220;composer&#8221;</td>
<td>Composer</td>
<td>&#8216;\251wrt&#8217;</td>
</tr>
<tr>
<td>&#8220;album&#8221;</td>
<td>Album</td>
<td>&#8216;\251alb&#8217;</td>
</tr>
<tr>
<td>&#8220;year&#8221;</td>
<td>Year</td>
<td>&#8216;\251day&#8217;</td>
</tr>
<tr>
<td>&#8220;track&#8221;</td>
<td>Track Number</td>
<td>&#8216;trkn&#8217;</td>
</tr>
<tr>
<td>&#8220;comment&#8221;</td>
<td>Comments</td>
<td>&#8216;\251cmt&#8217;</td>
</tr>
<tr>
<td>&#8220;genre&#8221;</td>
<td>Genre</td>
<td>&#8216;\251gen&#8217;</td>
</tr>
<tr>
<td>&#8220;copyright&#8221;</td>
<td>??</td>
<td>&#8216;\251cpy&#8217;</td>
</tr>
<tr>
<td>&#8220;description&#8221;</td>
<td>Description</td>
<td>&#8216;desc&#8217;</td>
</tr>
<tr>
<td>&#8220;synopsis&#8221;</td>
<td>Information dialog when selecting &#8220;Show Description&#8221; in context menu</td>
<td>&#8216;ldes&#8217;</td>
</tr>
<tr>
<td>&#8220;show&#8221;</td>
<td>Show</td>
<td>&#8216;tvsh&#8217;</td>
</tr>
<tr>
<td>&#8220;episode_id&#8221;</td>
<td>Episode ID</td>
<td>&#8216;tven&#8217;</td>
</tr>
<tr>
<td>&#8220;network&#8221;</td>
<td>??</td>
<td>&#8216;tvnn&#8217;</td>
</tr>
</table>
<p>Further, the MOV muxer encodes libavformat version string into the &#8216;\251too&#8217; field. Here&#8217;s an example that ties together all of the presently supported metadata options, even a few video options that don&#8217;t make sense for an audio file:</p>
<pre>
  ffmpeg -i track05.wav \
    -metadata title="Track #5" \
    -metadata author="Unknown Artist" \
    -metadata composer="Composer Unknown" \
    -metadata album="Tracer Video Game Soundtrack" \
    -metadata year="1996" \
    -metadata track="5" \
    -metadata comment="This is redbook CD audio track #5 from the Windows 95 game \"Tracer\"" \
    -metadata genre="Game Soundtrack" \
    -metadata copyright="Copyright 1996 Future Endeavors, Inc." \
    -metadata description="Nifty techno background tune for a futuristic video game" \
    -metadata synopsis="Hey, is this thing on? This is where the 'synopsis' field shows up." \
    -metadata show="Tracer" \
    -metadata episode_id="102" \
    -metadata network="Some network" \
    -acodec alac \
    -y track05.m4a
</pre>
<p>The lavf version shows up in the Summary tab of the informational dialog:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2009/12/itunes-encoded-with-lavf.png" alt="iTunes files encoded with FFmpeg&#039;s libavformat" title="iTunes files encoded with FFmpeg&#039;s libavformat" width="166" height="60" class="aligncenter size-full wp-image-2034" /><br />
</center></p>
<p>This is the Info tab of the same dialog:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2009/12/itunes-metadata-1.png" alt="iTunes Info dialog" title="iTunes Info dialog" width="660" height="614" class="aligncenter size-full wp-image-2035" /><br />
</center></p>
<p>Here is the video tab:</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2009/12/itunes-metadata-2.png" alt="iTunes video metadata" title="iTunes video metadata" width="660" height="614" class="aligncenter size-full wp-image-2036" /><br />
</center></p>
<p>And this is where the &#8220;synopsis&#8221; key shows up (selecting &#8220;Show Description&#8221; from the context menu):</p>
<p><center><br />
<img src="http://multimedia.cx/eggs/wp-content/uploads/2009/12/itunes-metadata-synopsis.png" alt="iTunes description dialog" title="iTunes description dialog" width="364" height="292" class="aligncenter size-full wp-image-2044" /><br />
</center></p>
<p>I don&#8217;t know where the &#8220;copyright&#8221; or &#8220;network&#8221; strings appear in various iTunes dialogs. But the strings are definitely encoded in the file.</p>
<p><strong>ASF/WMV/WMA</strong></p>
<p>FFmpeg&#8217;s ASF muxer honors the following metadata keys:</p>
<ul>
<li>&#8220;title&#8221;</li>
<li>&#8220;author&#8221;</li>
<li>&#8220;copyright&#8221;</li>
<li>&#8220;comment&#8221;</li>
</ul>
<p><strong>AVI</strong></p>
<p>FFmpeg&#8217;s AVI muxer honors the following metadata keys and maps them to these FourCCs in the file header:</p>
<ul>
<li>&#8220;Title&#8221; -&gt; &#8220;INAM&#8221;</li>
<li>&#8220;Artist&#8221; or &#8220;Author&#8221; -&gt; &#8220;IART&#8221;</li>
<li>&#8220;Copyright&#8221; -&gt; &#8220;ICOP&#8221;</li>
<li>&#8220;Comment&#8221; -&gt; &#8220;ICMT&#8221;</li>
<li>&#8220;Album&#8221; -&gt; &#8220;IPRD&#8221;</li>
<li>&#8220;Genre&#8221; -&gt; &#8220;IGNR&#8221;</li>
<li>&#8220;Track&#8221; -&gt; &#8220;IPRT&#8221;</li>
</ul>
<p>Further, if the bit-exact flag is not explicitly specified (using &#8216;-flags bitexact&#8217;, the muxer will also encode the libavformat version string into the &#8220;ISFT&#8221; field.</p>
<p><strong>Matroska</strong></p>
<p>Per my reading of libavformat/matroskaenc.c, the muxer only supports 3 keys. This surprises me&#8211; I always thought MKV was supposed to be a container format to end all container formats; maybe FFmpeg&#8217;s muxer just doesn&#8217;t support many of the tags available; or perhaps the format embeds some other metadata format. Whatever the case, these are the only metadata keys that the muxer supports:</p>
<ul>
<li>&#8220;title&#8221;</li>
<li>&#8220;description&#8221;</li>
<li>&#8220;language&#8221;</li>
</ul>
<p><strong>MP3</strong></p>
<p>According to libavformat/mp3.c, the following metadata keys are supported:</p>
<ul>
<li>&#8220;title&#8221;</li>
<li>&#8220;author&#8221;</li>
<li>&#8220;album&#8221;</li>
<li>&#8220;year&#8221;</li>
<li>&#8220;comment&#8221;</li>
<li>&#8220;track&#8221;</li>
<li>&#8220;genre&#8221;</li>
</ul>
<p><strong>MPEG Transport Streams</strong></p>
<p>The libavformat/mpegtsenc.c file indicates that the muxer honors the metadata keys &#8220;title&#8221; and &#8220;language&#8221;.</p>
<p><strong>NUT</strong></p>
<p>FFmpeg&#8217;s NUT muxer honors the following metadata keys:</p>
<ul>
<li>&#8220;title&#8221;</li>
<li>&#8220;author&#8221;</li>
<li>&#8220;copyright&#8221;</li>
</ul>
<p><strong>Realmedia</strong></p>
<p>FFmpeg&#8217;s Realmedia muxer encodes a &#8220;CONT&#8221; chunk by concatenating certain metadata values specified on the command line. These are the recognized metadata keys:</p>
<ul>
<li>&#8220;title&#8221;</li>
<li>&#8220;author&#8221;</li>
<li>&#8220;copyright&#8221;</li>
<li>&#8220;comment&#8221;</li>
</ul>
<p>Example:</p>
<pre>
  ffmpeg -i track05.wav \
    -metadata title="This is the title" \
    -metadata author="Made by Me" \
    -metadata copyright="Copyright 2009 Me"
    -metadata comment="An exercise in Realmedia metadata" \
    -y track05.rm
</pre>
<p>This is what the start of the file looks like in a hex editor:</p>
<pre>
0040   00 01 00 03  43 4F 4E 54  00 00 00 5F  00 00 00 11  ....CONT..._....
0050   54 68 69 73  20 69 73 20  74 68 65 20  74 69 74 6C  This is the titl
0060   65 00 0A 4D  61 64 65 20  62 79 20 4D  65 00 11 43  e..Made by Me..C
0070   6F 70 79 72  69 67 68 74  20 32 30 30  39 20 4D 65  opyright 2009 Me
0080   00 21 41 6E  20 65 78 65  72 63 69 73  65 20 69 6E  .!An exercise in
0090   20 52 65 61  6C 6D 65 64  69 61 20 6D  65 74 61 64   Realmedia metad
00A0   61 74 61 4D  44 50 52 00  00 00 9B 00  00 00 00 00  ataMDPR.........
</pre>
<p><strong>Odds &#8216;n Ends</strong></p>
<p>The SDP muxer honors the &#8220;title&#8221; metadata key. </p>
<p>The SoX native format muxer honors &#8220;comment&#8221;.</p>
<p><strong>Observations and Conclusions</strong></p>
<p>The craziest part I notice is that the example provided in the official documentation showed how to set metadata for a FLV file. However, the FLV muxer does not honor any metadata keys. This could be that FLV metadata is highly free-form and wholly dependent on what the client player SWF cares about. <a href="http://www.adobe.com/devnet/flv/">The official FLV spec</a> describes the onMetaData tag which allows a FLV to encode metadata which will be presented to an ActionScript program via Netstream.onMetaData. Really, though, this just means that this should be the easiest format for metadata support; just iterate through each key/value pair and write it to an onMetaData tag.</p>
<p>I was slightly disturbed by the case inconsistency seen between a few of the muxers. A few of them (like AVI) specify &#8220;Title&#8221; while most specify &#8220;title&#8221;. However, digging in libavformat/metadata.c reveals that the default behavior is to treat the metadata keys as case-insensitive unless a certain flag is specified, which is never specified.</p>
<p>For completeness, it looks like we should add some other fields as well. For the MP4 muxer: &#8216;\141ART&#8217; (Album Artist, vs. Artist which is &#8216;\251ART&#8217;), &#8216;\251grp&#8217; (Grouping), &#8216;\251lyr&#8217; (Lyrics), &#8216;tvsn&#8217; (Season Number) and &#8216;tves&#8217; (Episode Number), and perhaps any other minor options, if the mood strikes. If you see some omissions with metadata types for other formats, you may want to chime in. I also notice that Ogg and FLAC are not hooked up to the metadata API while both formats support such information.</p>
]]></content:encoded>
			<wfw:commentRss>http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

