I've been fighting for three days straight to send a sad five-minute video of the latest Counter-Strike 1.6 tournament we set up at the neighborhood LAN party. I tried sending it over Messenger, but upon reaching 90% the connection crashed and I almost smashed my keyboard against the monitor. The desperation is real when you have a sad 256 kbps Telefónica ADSL.

Sick of banging my head against the wall, a buddy from IRC yesterday sent me a link to a website called YouTube.com. Apparently, the idea is that you upload your video to their server, and they convert it to Flash (.flv format) so anyone can watch it directly from the browser, without downloading players or worrying about codecs. All for free. It sounds like black magic to me, but I started tinkering and hey, it works.

So, so you don't have to suffer like me, I'll leave you the recipe I've polished today fueled by coffees to capture the footage, smash the size down to something reasonable and upload it to this invention.

The capture: The gigabyte hell

If you're recording from the PC (a match or a tutorial), you're definitely using Fraps. The huge problem with Fraps is that it spits out AVI files without any compression. Recording a couple of minutes at a decent resolution (like 640x480) melts several Gigabytes off your IDE hard drive in the blink of an eye.

If you're coming from a MiniDV camera via FireWire cable, you'll have something similar. A massive raw file. YouTube only lets you upload 100 MB per video, so if you try to send that as is with our connection, you'll retire before it finishes. We have to compress.

Extreme compression with MEncoder

You can use VirtualDub if you're the type who prefers clicking around, but here we like typing commands into the console. For this, MEncoder (which comes with MPlayer) is a godsend on Linux, although it also works perfectly on Windows.

We're going to turn that monstrosity into something manageable using the free Xvid codec for video and MP3 for audio. YouTube recommends a 320x240 resolution, so while we're at it we'll scale it down to scrape off some megabytes.

Open your terminal and throw this in:

mencoder captura_gigante.avi \
  -vf scale=320:240 \
  -ovc xvid -xvidencopts bitrate=600 \
  -oac mp3lame -lameopts cbr:br=64 \
  -o video_youtube.avi

What exactly are we doing here? * -vf scale=320:240: We crush the resolution to what YouTube's player uses by default. We'll save a ton of space and avoid them doing a crappy downscale later. * -ovc xvid: We tell it to compress with Xvid. A 600 kbps bitrate yields a pretty decent quality for that resolution. * -oac mp3lame: We convert the audio to MP3 at 64 kbps. To hear the game's gunshots or my nasal voice, it's more than enough.

After the hard drive finishes grinding, the video that weighed 2 GB is left at a wonderful 15 or 20 MB.

Upload to YouTube and pray

You create an account (it just asks for an email and a nick, no complications), hit the huge "Upload" button and select your video_youtube.avi.

Now it's time to arm yourself with patience. With the 128 kbps upload speed we lucky ones with ADSL have, those 20 megabytes will take about 25 minutes. Go make yourself another coffee. When it's done, the site spends a while thinking (I guess processing the Flash on their servers) and in the end it spits out a URL. You can now paste that link in forums, send it via Messenger or embed it in your blog with a snippet of HTML.

Late night reflections

Honestly, I don't know what future awaits this video site. Hosting so much video on the internet costs an awful lot of money in bandwidth. Internet access has to get cheaper, and infrastructure needs to improve to gain speed and deregulate access for companies to offer network services. On Youtube they don't have ads anywhere and letting anyone upload 100 MB videos for free seems like an unsustainable business model to me. They'll surely end up throwing in ads because servers don't pay for themselves.

But while it lasts, it's the best invention for sharing our matches or silly videos without saturating our blog server or having to split files into 20 chunks to email them. Take advantage of it!