BoobTube


I've been looking at the technical details of optimising video for putting on YouTube.

If you know something about computer video, this post may be useful to you. If you don't...it'll be roughly as interesting as a brochure of granite samples.

When you upload your videos to YouTube, you can use many possible formats for the video and audio streams. The video stream can be in MPEG1, MPEG2, DivX, XviD, WMV and several others, but not FLV.

The audio stream can be in WAV, AIFF, MP3, MP2 or the built in format used by WMV. It can be stereo or mono, and any of the common samplerates - 22KHz, 44.1, 48 etc.

However, YouTube will always recode what you upload into FLV - Flash Video, which uses MP3 for sound. The MP3 is always 22KHz, mono, and at a variable bitrate between 32kbps and 64 - okay for speech, but not great for music.

This means if the sound track of your upload is in MP3, it will be recoded into another MP3, a process which sometimes throws the sound out of synchronisation with the video.

It also means that if you upload a stereo file, you should be aware that changing it to mono can change the loudness of sounds that are panned left or right. If you're uploading a song, the vocals might become significantly quieter, or the mix different.

So, mix your song down to mono, and make sure it sounds okay before uploading. I'm not sure, but I think if your upload soundtrack is in MP3 at 22KHz, in mono at (say) 256kbps, this should reduce sound drift, and it'll sounds as good as it's going to get after recoding.

I think the video bitrate Youtube recodes to is constant, but I don't know what it is.


The file you upload can be anything up to 100MB, and up to ten minutes long.

Whatever video resolution you use, YouTube will recode it to 320x240, so it's a good idea for your upload to be 320x240 too. That way (a) you don't waste bandwidth uploading pixels that won't appear onscreen. (b) you have to wait less time for YouTube to process your upload and most importantly (c) you can use your megabytes to encode your 320x240 film at a very high bitrate, making it nearly lossless, meaning the degradation caused by YouTube recoding it to FLV will be minimised.

That is, if you give YouTube the best picture quality you can, it will look better when they've finished with it. If you're encoding to an MPEG4 format (probably DivX or XviD), 2000kbps CBR is as high as you need to go. You can go higher, but bitrates above 3000 can make the picture worse by carefully encoding visual noise in the picture, which lower bitrates would ignore.

Incidentally, Google Video can accept videos at 640x480. I'm not certain what bitrates are best, but personally I think 2000 is fine here too.

All YouTube videos are 320x240 pixels. However, when you embed one in your blog, the default size is 425x350, and they display at the same size on YouTube's own site. This means:

(1) The video is displayed scaled up by an awkward proportion, which has the effect of reducing picture quality.

(2) The right hand side of the video will be cut off on a Blogger blog, because the space allowed for blog entries is slightly narrower than the width of the video.

It looks like this:



See how the right hand side is cut off? And no, that is not me singing,

Why does YouTube choose do this? I have no idea.

However, you can change the display size, either to make it fill up the width of your blog without cropping, or to display in best picture quality without resizing.

The code to embed a video is provided by YouTube on each video's page for cutting and pasting, and looks like this:

<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/LOO67TPIsdY"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/LOO67TPIsdY" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>


See that there are two mentions of width being 425 and height being 350? The first time refers to the dimensions of the "box" which contains the player for the video clip. The second gives the size of the player.

To make the clip as large as the blog column, change both widths to 400 and both heights to 300. This will also make the video display slightly better, because the scaling factors are "neater" - 400 is 320*1.25 and 300 is 240*1.25. You're making the video window larger by a quarter, instead of the default of almost-but-not-quite a third.

Like this:


To make the clip display with the best quality, set to the widths and heights to the dimensions of the FLV file - 320x240.

Like this:


If you're posting YouTube clips somewhere that doesn't have Blogger's narrow columns, you might consider making the width 640 and the height 480 - double in both direction. This will make bad quality video look worse, but will give you a nice big window.

2 comments:

  1. Could we get a video of you singing. 'Cause to tell you the truth, I'm still thinking you look like Hugh Laurie

    ReplyDelete
  2. Even when he pretends to be the American Kapitano he's much nicer than Hugh Laurie.

    ReplyDelete