{"id":3143,"date":"2011-02-08T22:40:23","date_gmt":"2011-02-09T06:40:23","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=3143"},"modified":"2011-02-09T00:18:13","modified_gmt":"2011-02-09T08:18:13","slug":"googles-youtube-uses-ffmpeg","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/googles-youtube-uses-ffmpeg\/","title":{"rendered":"Google&#8217;s YouTube Uses FFmpeg"},"content":{"rendered":"<p>Controversy arose last week when <a href=\"http:\/\/googleblog.blogspot.com\/2011\/02\/microsofts-bing-uses-google-search.html\">Google accused Microsoft of stealing search engine results<\/a> for their Bing search engine. It was a pretty novel sting operation and Google did a good job of visually illustrating their side of the story on their official blog.<\/p>\n<p>This reminds me of the fact that Google&#8217;s <a href=\"http:\/\/www.youtube.com\/\">YouTube<\/a> video hosting site uses <a href=\"http:\/\/ffmpeg.org\/\">FFmpeg<\/a> for converting videos. Not that this is in the same league as the search engine shenanigans (it&#8217;s perfectly legit to use FFmpeg in this capacity, but to my knowledge, Google\/YouTube has never confirmed FFmpeg usage), but I thought I would revisit this item and illustrate it with screenshots. This is not new information&#8211; I first <a href=\"http:\/\/multimedia.cx\/eggs\/poking-at-youtube\/\">empirically tested this fact 4 years ago<\/a>. However, a lot of people wonder how exactly I can identify FFmpeg on the backend when I claim that I&#8217;ve written code that helps power YouTube.<\/p>\n<p><strong>Short Answer<\/strong><br \/>\nHow do I know YouTube uses FFmpeg to convert multimedia? Because:<\/p>\n<ol>\n<li>FFmpeg can decode a number of impossibly obscure multimedia formats using code I wrote<\/li>\n<li>YouTube can transcode many of the same formats<\/li>\n<li>I screwed up when I wrote the code to support some of these weird formats<\/li>\n<li>My mistakes are still present when YouTube transcodes certain fringe formats<\/li>\n<\/ol>\n<p><strong>Longer Answer (With Pictures!)<\/strong><br \/>\nLet&#8217;s take a <a href=\"http:\/\/wiki.multimedia.cx\/index.php?title=ROQ\">video format named RoQ<\/a>, developed by noted game designer <a href=\"http:\/\/www.mobygames.com\/developer\/sheet\/view\/developerId,2913\/\">Graeme Devine<\/a>. Originated for use in the FMV-heavy game <a href=\"http:\/\/www.mobygames.com\/game\/11th-hour\">The 11th Hour<\/a>, the format eventually found its way into the Quake 3 engine as well as many games derived from the same technology.<\/p>\n<p>Dr. Tim Ferguson reverse engineered the format (though it would later be <a href=\"http:\/\/multimedia.cx\/eggs\/quake-3-source-code-available-and-roq-engine-too\/\">open sourced along with the rest of the Q3 engine<\/a>). I wrote a RoQ playback system for FFmpeg, and I messed up in doing so. I believe my coding error helps demonstrate the case I&#8217;m trying to make here.<\/p>\n<p>Observe what happened when I pushed the <a href=\"http:\/\/samples.mplayerhq.hu\/game-formats\/idroq\/\">jk02.roq<\/a> sample <a href=\"http:\/\/www.youtube.com\/watch?v=9KaOfvKCSH0\">through YouTube<\/a> in my original experiment 4 years ago:<\/p>\n<p><center><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/youtube-erroneous-roq-conversion.jpg\" alt=\"\" title=\"YouTube erroneously converts an obscure type of multimedia format\" width=\"648\" height=\"455\" class=\"aligncenter size-full wp-image-3144\" srcset=\"https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/youtube-erroneous-roq-conversion.jpg 648w, https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/youtube-erroneous-roq-conversion-300x210.jpg 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><br \/>\n<\/center><\/p>\n<p>Do you see how the canyon walls bleed into the sky? That&#8217;s not supposed to happen. FFmpeg doesn&#8217;t do that anymore but I was able to go back into the source code history to find when it did do that:<\/p>\n<p><center><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/roq-ffmpeg-error.jpg\" alt=\"\" title=\"FFmpeg erroneously decoding RoQ video\" width=\"528\" height=\"558\" class=\"aligncenter size-full wp-image-3147\" srcset=\"https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/roq-ffmpeg-error.jpg 528w, https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/roq-ffmpeg-error-283x300.jpg 283w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><br \/>\n<\/center><\/p>\n<p><strong>Academic Answer<\/strong><br \/>\nFFmpeg fixed this bug in June of 2007 (thanks to <a href=\"http:\/\/icculus.org\/~riot\/\">Eric Lasota<\/a>). The problem had to do with premature colorspace conversion in my original decoder.<\/p>\n<p><strong>Leftovers<\/strong><br \/>\nI tried uploading the video again to see if the problem persists in YouTube&#8217;s transcoder. First bit of trivia: YouTube detects when you have uploaded the same video twice and rejects the subsequent attempts. So I created a double concatenation of the video and uploaded it. The problem is gone, illustrating that the backend is actually using a newer version of FFmpeg. This surprises me for somewhat esoteric reasons.<\/p>\n<p>Here&#8217;s another interesting bit of trivia for those who don&#8217;t do a lot of YouTube uploading&#8211; YouTube reports format details when you upload a video:<\/p>\n<p><center><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/youtube-upload-format-information.png\" alt=\"\" title=\"YouTube reports format information\" width=\"614\" height=\"286\" class=\"aligncenter size-full wp-image-3149\" srcset=\"https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/youtube-upload-format-information.png 614w, https:\/\/multimedia.cx\/eggs\/wp-content\/uploads\/2011\/02\/youtube-upload-format-information-300x139.png 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><br \/>\n<\/center><\/p>\n<p>So, yep, RoQ format. And you can wager that this will prompt me to go back through the litany of unusual formats that FFmpeg supports to see how YouTube responds.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual evidence that YouTube uses FFmpeg on its transcoding backend<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3143","post","type-post","status-publish","format-standard","hentry","category-general"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=3143"}],"version-history":[{"count":8,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3143\/revisions"}],"predecessor-version":[{"id":3154,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/3143\/revisions\/3154"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=3143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=3143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=3143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}