Know something we should know? E-mail us your tips! We respect anonymity. »
Help-Key: How to Optimize Your Video for YouTube
  • 93 Comments
by Matt Hickey on July 16, 2007

picture-102.jpgWhen I say things like this, my friends roll their eyes, but it’s how I actually talk. I say things like, “Let’s talk about video compression!” They buy another drink. But that’s what we’re doing in today’s Help-Key, and it’s something I actually get to do for a living (besides blogging, duh).

YouTube is getting huge. Somehow, despite the lack of a coherent business model, it’s become one of the most popular destinations on the Internet, and rightly so: the idea that anyone can become some sort of memestar by uploading a simple video is great. And because the site does its own Flash conversion, it’s a piece of cake. The thing is, though, with digital video garbage in means garbage out.

You may have noticed that some videos on YouTube simply look better than others. This is because they came from better sources. With a little tweaking and a little know-how, you can prepare your video for YouTube in a way that spares us all from oversized pixels.

The first step is knowing what format you’re starting with. Most digital cameras today shoot video, as do most phones, which is a great cheap way to start. Sadly, the videos created tend to be worse than that 3rd-gen VHS copy of Cheerleader Carwash 8 you found under your brother’s bed. If you can, pull your video from a digital camcorder. Most Mini-DV cameras include Firewire out, so if you’ve got a fairly recent Mac you’re set. Or you can get a Firewire card for your Peecee pretty cheap.

picture-101.jpgBut no matter where your video comes from, the onus is on you to make it awesome. There are plenty of editing tools on the Internet for any platform you wish, and the latest computers actually have tools bundled with the basic install for just such casual editing. And they’re easier to use than you think. You’re not Kubrick, so you don’t need Final Cut Pro or Premiere. I personally use the $30 pro version of Quicktime, because it’s fast and has drag-n-drop editing, which is nice.

If you can avoid it, don’t use the Windows Movie Maker. The program handles things with tricky Windows Media codecs and black magic and the blood of virgins. Also, if you’re using a cellphone video source, it’ll vomit on you. Quicktime plays nice with about anything, and the pro version can be had on any PC or Mac.

picture-98.jpgOnce you’ve got your clip looking pro, you’re going to want to make it YouTube ready. YouTube can only take certain formats for input, so this is where it gets tricky. You’ll want to make a .mov or .mp4, so make sure whatever editor you’re using can hack it. If not, you’ll need to do a conversion, and that’s no rock n’ roll fun, and you lose information during the transition, so best just leave it alone.

Your newly formed video should be set to the YouTube-native size of 320×240 (aka QVGA). I know, I know: here we are in the world of HiDef, and I’m telling you to shrink your vids. I’m just the messenger, ya know?

picture-97.jpgIt’s also worth noting that your camera might shoot at a different aspect ration than the 4:3 that is 320×240. If so, you’ll have to do a little letterboxing. It does king of suck, but it’s better than the stretch and pull method that would happen otherwise.

When YouTube’s servers encode your video, it’s going to lose some quality, it’s a fact of streaming media. That means you’re going to want to make it as bit-rich as you can. Use a bitrate as high as you can, YouTube can take it. That being said, anything above 1200kbps is probably overkill and will take the video longer to process on YouTube’s end. Somewhere between 700kbps and 1000kbps should do the trick nicely.

picture-100.jpgNow that we’ve got size, codec, and quality set up, choose your audio. You’ll want to use the MP3 audio codec (either CBR of VBR), which should be standard on your editor.

Output your file as a .mov or .mp4 and preview it. It should look pretty good (if small). If you’re satisfied, do your upload. After it’s on the servers, it can take up to an hour or more to display. This is because YouTube is formatting it and encoding it for their Flash streaming. It’s an automated process, but by following the guide above, it makes less work for the YouTube servers. This isn’t altruistic, however: you did some of their work for them, but since you were in control, you made it better than they could. This means that your video will look better than most, and will encode faster. Double bonus, pal.

Test it out and tell us what you think. If you’ve got some other tips, feel free to share them in the comments thread for this story. Also note that there’s software out there that has automated YouTube features, such as VirtualDub. These programs are great time-savers if you’re and hardcore YouTuber, and they should be considered.

Enjoy, readers, and we’ll see you on our screens soon.

Comments rss icon

  • Bravo, Matt – I’d been wondering if there were secrets to quality YouTube compression. Most YouTube videos look like crap, if you ask me – so any advice on how to get it right is the opposite of “king of suck”.

  • Dude, Most “peecee’s” come with firewire, they have for years. Also Windows Media Encoder 9 can do a great job on You Tube.

  • Hi Matt – Thanks for sharing your hints. Together with YouTube’s own quality optimization FAQ (http://www.google.com/support/youtube/bin/answer.py?answer=55745&topic=10526), this blog entry hopefully helps users getting the best out of YouTube. I have written a “HOWTO make a screencast with Mac OS X” tutorial, intuitively I respected most of your hints… http://blog.tomayac.de/index.php?date=2007-07-13&time=11:25:36&perma=HOWTO+make+a+screenc.html.

  • hi,
    when i output my .mov files the files are insanely huge.. like a 1 min video is 51MB. I tried all different settings inside the compressor drop-down.. everything from vfw to h.263(?), etc.. also when I winrar the file it comes down to like 10MB so i’m guessing something is amiss somewhere in the qt compression..

    any ideas?

    great article btw..

    regards,
    san

  • can we get that Untitled 2 video from somewhere? :P

  • I didn’t quite follow why not to use “Windows Movie Maker”.

  • Definitely with a Mac it’s so much easier. The other thing, you’ll need plenty of disk space so getting big external drives are a must.

  • What about framerate? 15, 30, or 60fps?

  • Nice article. I have one question: I’m confused about the h.264 compression Youtube is using for Apple TV and iPhone videos.

    Is this simply a Flash alternative, or will it give better resolution, thus making me wish I had encoded with a larger screen res; higher quality? I’d love to hear your thoughts.

    Thanks again,
    Jeff

    • video compression. It is also known as MPEG-4 Part 10, or MPEG-4 AVC (for Advanced Video Coding). It is latest block based motion estimation based codec developed by the ITU-T Video Coding Experts Group (VCEG) together with the ISO/IEC Moving Picture Experts Group (MPEG) as the product of a partnership effort known as the Joint Video Team (JVT). The ITU-T H.264 standard and the ISO/IEC MPEG-4 Part 10 standard (formally, ISO/IEC 14496-10) are jointly maintained so that they have identical technical content. The final drafting work on the first version of the standard was completed in May 2003.

  • Do you have a link to a video on youtube that uses this technique? I would love to see a video that uses it compared to the same video that does not just to see the difference in quality.

  • San: are you sure you’re setting it to output video at the right size? 50 megs for one minute of footage is pretty darn huge. Using Quicktime Pro I usually just let it rip, exporting as MP4 and using its recommended settings. Typically I get around 2-5 megs per minute of footage, depending on whether I slide the quality scale up or down.

    Gdude: 30 fps looks best when you’re watching a video as quicktime or mp4, but doesn’t youtube autoconvert to 15 fps anyway? So if youtube is your only outlet, there’s nothing wrong with 15 fps. I still prefer to export my videos at 30fps, since I also use blip.tv for posting my video to my video blog. So while Youtube sometimes gives me a bigger audience, the footage served by blip looks more like what I intended. I also can’t think of a reason to use 60fps. The only time I ever use it is when I’m planning to edit something and use a slo-mo effect. Otherwise I always stick to 30fps.

    You may also want to check out http://www.freevlog.org. They’ve got some great free tutorials for video bloggers, including compression suggestions.

  • I use Final Cut 5 and Compressor. I export it as Web Streaming H.264 300kbps and the outcome is good.

  • On linux, there’s a great tool, ffmpeg. Use it from the commandline:
    fmpeg -i input.mov -vcodec mpeg4 -acodec mp3 -s 320×240 -b 1000k output.mp4

    it wil convert allmost every input format into allmost every other format..

    cheers

  • ffmpeg in the commandline that is, not fmpeg…

  • Great write up and is perfect for what I have been researching. I have been writing on good ways to publicize and distribute your videos online but this goes hand in hand with getting a good product (video) out in the market. with this helpful write up that you have outlined above I think that it will add to the attractiveness of the online viewing experience.

    john griffin

  • There is another good YouTube encoding tutorial, at LAFCUG. If you want the best quality encode use QuickTime H.264, and upload to blip.tv. They maintain the original QT movie, but also re-encode a second version to Flash. A 400 kbps data rate is usually fine for 320×240, but they also take larger videos, I’m up to 448×336. They generate some nice QT or Flash embed code for blogs also.

    MIT has started using blip.tv for their videos. Nothing wrong with YouTube though, it’s got the audience…

  • Do these tips hold true for Google Video as well?

  • If you convert your videos to Flash before you upload, you can get considerably better results than uploading them as QuickTime and letting YouTube do the conversion.

    • I have not found that to be true. Also, if you upload a high-quality .MOV file, YouTube now adds a link under the video player for “higher quality video”. If you upload as Flash Video, that link/option does not appear.

    • I have not found that to be true. Also, if you upload a high-quality .MOV file, YouTube now adds a link under the video player for “higher quality video”. If you upload as Flash Video, that link/option does not appear.

  • The only part of this I dont understand is why is he telling people to put mp3 audio into an .mp4 container, this is against spec and will break many players. Best to leave it as AAC.

  • You had to get an MS bash in there didn’t you?

  • @Ben: Its because YouTube uses mono mp3 for its audio. Again, you’re doing the work for YouTube.

  • Great article dude. I’ll have to try this next time I upload to YouTube.

  • great article but one comment:

    Why do mac people think PC people don’t have firewire? My PC came with it standard. Every PC I’ve built since 2000 has had at least one firewire port directly in the back of the motherboard.

  • I agree with the other wookie…got a link to untitled 2

    BTW nice article.

  • I have disagree that mp4 is the way to go , to get clearer video, and Youtube is the way to go to upload….

    I use linux and XVID (divx) codec rocks. below is the command i use.

    mencoder -ovc xvid -oac mp3 -xvidencopts bitrate=1100 -vf scale=640:400 -o outputclipname.avi youroriginalfile.mpg (or .mov or anything).

    see results at brightcove >> http://www.brightcove.com/title.jsp?title=1114268305&channel=1080168798

  • @Austin, yes YouTube uses mp3, but they re-encode anything you upload, so it gets transcoded anyways. The issue is what format least suffers through the recompression.

    Same with flash-encoded uploads, they re-encode anyways. That’s why so much of YouTube video has poor visual quality. (no comment on the content!)

    @drew. XVID (divx) is part of the MPEG4 standard, specifically Part 2 Advanced Simple Profile. The above tutorial encodes using Part 2 Simple Profile, which is not considered as efficient.

    H.264 is MPEG4 Part 10, which is considered the most efficient. Efficiency meaning attainable quality at specific data rates.

    Compression quality can depend more on the implementation (developer) of the specific codec, the software used to encode, and the setting used, than the codec itself. That’s why you see several successful approaches to the same problem. The characteristics of the video (high-motion, lots of chroma, gradients, fine detail, etc.) has a lot to do with the final results.

  • So where’s the video with the girl in it?

  • where’s the chick video?

  • Has anyone experienced this same gray glitch problem when using Quicktime Pro to convert your video for YouTube…

    I export the video via QT Pro on my PC using 320×240 QVGA, 30 FPS, 1000bps, H.264. On my local computer, the video looks great. However, whenever I upload the video to YouTube, I get a glitch for the first 5+ seconds where the video is gray (minimal colors). After the 5 seconds, the color all pops into place. It is like YouTube is missing the first frame of data (keyframe) where the first picture (along with all of the color) is set. So the first 5 seconds only shows the difference in each subsequent frame.

    Has anyone seen this same problem? Any ideas for a resolution?

    Thanks,
    Ben

  • I’m surprised nobody mentioned that the footage affects compression and quality. If you shoot with a tripod you are going to get much better compression than if you shoot handheld. This is because the less information that is moving the more the compression algorithm can “freeze” through consecutive frames. More information moving on screen means more data to remember and store. Resulting in larger files and less optimization.

  • who owns a mac?

  • @ben, did you try not selecting Frame Reordering, putting in a keyframe every 2 or 3 seconds, and Optimizing for CD ROM when encoding?

    @todd…nice troll, but kind of irrelevant to the discussion.
    Before this turns into a food fight, you should know that QuickTime and the Pro version generally work just as well on Windows as they do on OSX. Along with many other codecs.

  • Re: Untitled 2

    This is actually just a single clip, much like Untitled next to it, that is currently being edited into a video to appear on YouTube shortly entitled “Hawt Nights: The Erotic Scrapbook of a Gadget Blogger”. It will be uploaded this fall. Watch for it.

    Also, @ Kevio: You’re totally right. The tone of this guide, though, wasn’t so much for prosumers but for the “OMG look what sean did! Did you get that on tape!?” crowd, which tend to be handheld-users. You are, though, absolutely correct, and thank you.

  • This article came close, but is missing a few things. For starters, and since YouTube is going to recompress whatever you give it, your goal should be to get the file into the highest res format that they will accept. So, personally, for me this means:

    1. Use 640×480 source b/c that gives youtube more resolution to work with when they re-encode down to 320×240. (Alternate opinion: do the resize yourself because you think you have better software to do it, that said, they’ll just re-encode your 320×240 source back to 320×240 again, so why not give them more to work with?).

    2. Use the HIGHEST bit rate combination for audio and video that you can and still stay under the 100mb upload per video limit. Again, this allows you to give YouTube the best possible source quality that they will accept, so when they run it through their transcoder, they’re starting with a nice clean source. Some encoders will let you set a target file size, so that is perfect, shoot for 90 mb, and you’re golden. (Alternate perspective: maybe this is overkill, but chances are your original source is MPEG2 or DV quality, so why not tap as much bit rate as they’ll let you. Also, the obvious downside is a longer upload time, but it’ll be worth it, trust me).

    3. Frame rate. This one’s tougher. YouTube is going to encode it down to 15 fps no matter what you upload, so you might be better off getting the cleanest 15 fps source you can in a good editor/encoder before uploading. On the other hand, if their encoder is good, you might want to feed it 30 fps so it can interpolate between frames itself with that higher bit rate source and 640×480 resolution.

    Anyway, the KEY POINT is that they let you upload 100 mb file, so you should take every advantage of that you can, giving them the highest bit rate source to start with that still meets their upload requirements. Trust me, this one thing alone will do more for end-result quality than any of those tips mentioned above!

    • Hi,
      I tend to agree with you. Even Youtube recommends 640×480 uploads. Are most recommending 320×240 uploads just to keep long vids under the 100MB mark?

      However, I do believe youtube allows 30fps, at least that’s the info displayed on some of the vids I’ve downloaded from them for analysis.

      If the goal is to get as close to 100MB as possible then I guess there are two options:
      1. 640×480 at a lower bit rate
      2. 320×240 at the highest bit rate possible, just below overkill

      After youtube encodes, which leaves you with the better quality? I guess that is the question.

  • Is QT Pro free?
    Nope.

    Windows media maker is free and by the way, no problem on this end with it. I have a bootlegged version of Premiere but WMM is very quick and I can see why its popular even though you can do little with it.

    Lets see if you can do an article where youre not whoring for Apple or maybe suggest some free programs for the pc. Let me guess, youre a Mac user and dont know any, right?

    Its pretty lazy of you to not have ONE single suggestion for software.
    If someone had paid for you to write this article they could have asked for their money back.

  • I wouldn’t wipe my ass with your “article” for fear of rubbing some intelligence on it.

  • As an avid YouTuber, I found your article to be very correct. I receive many requests regarding video “clarity” and I’m glad I can send them to this article instead of retyping an answer all over again.
    Thanks!

  • ffmpeg was mentioned in this thread. a ffmpeg developer discovered that youtube uses ffmpeg internally. If you want the ‘best’ quality, you should convert your video to flv using ffmpeg because when you upload the video it won’t do ANY conversion. Perhaps if the bitrate is too high or something it will re-encode. You can test if the video was modified by uploading it, downloading the flv file and comparing the two files for changes. Then, you can see if youtube re-encodes your flv, but i believe it doesn’t.
    http://ffmpeg.mplayerhq.hu/

  • With the unbelievable popularity YouTube has amassed over the last couple years, I can’t believe they still don’t offer anything at a higher resolution than 320X240, I know it will just eat more bandwidth….but google should be able to handle at least some 480p vids…maybe not for embedded to other sites, but when you watch it on their site with all the ads surrounding it.

    PS: If you’re running Linux/Unix (which include OSX), there are alot of great graphical video tools out there too ;) Look at Diva, Pitivi…and if you’re looking for extremely high quality (with a high learning curve too unfortunately) there’s always Cinerella. But yes, there are also lots of command line, transcoding tools like mentioned above (although I’ve yet to see anyone mention VLC yet, which is also a great option and works on Linux, Mac AND Windows).

  • andy carvin: thanks for the help.
    http://www.google.com/support/youtube/bin/answer.py?answer=55745&topic=10526 says 30fps, but i figure I’ll just keep ti 30fps and let youtbue do the rest, i asked because i asumed making youtube do it would further degrade the quality. (like letting websites resize images for you)

  • There appears to be a lot of incorrect advice on this thread, supported by opinions – rather than facts. Note that getting the BEST POSSIBLE quality from YouTube can be determined empirically…

    I performed a set of tests in April to determine what worked best for me. I recorded a clip using a Flip Video Camcoder from Pure Digitial Technologies, loaded it into Adobe Premiere Elements 3.0.2 on Windows XP, outputted a range of different files and uploaded them to YouTube.

    The original source file (recorded on the Flip Video Camcorder) was 45 secs long, recorded outside in sunlight, and contained a moderate amount of movement. The video stream was XVID codec, 640×480 resolution, 30 frames per sec. I ignored the audio stream as I wanted to compare only video quality.

    I outputted files with different formats (Windows Media, QuickTime formats), different resolutions (640×480, 320×240), different frame rates (30 FPS, 15 FPS), and different bit rates (500 kbps, 1500 kbps, 3000 kbps). After all files were uploaded to YouTube and then compared, it became clear that:
    – 30 FPS is much better than 15 FPS;
    – 1500 kbps is much better than 500 kbps, but 3000 kbps was no better than 1500 kbps;
    – there is no discernable difference between 640×480 and 320×240;
    – Windows Media is sharper and a bit more vibrant than QuickTime (which people tend to prefer on something like YouTube).

    Since then, I’ve always uploaded as Windows Media, 320×240, 30 FPS, 1500 kbps. Simple…

  • But isn’t it true that YouTube are now using H264 for AppleTv and iPhone and are working on putting their entire back catalogue on H264? I’ve been uploading to YouTube using H264 on dv and now on HD but the results vary. I still haven’t found the “perfect” setting. Depends on the original vid.

  • @ben YES i have the same gray 5 seconds problem. i also encoded with visualhub though so can’t blame qt pro. this is so annoying. i’m trying to upload a video for the debate, and can’t submit something with 5 seconds of gray crud

  • alright, lots of views here but no facts for the beginners. My question is what is the bitrate that youtube reencodes to when we upload our videos? Is it a variable or fixed? What is the allowed max bitrate? Does youtube fail to process a video if it has way too much bitrate?

  • Youtube should just start using Flash 8! The Vp6 codec will cut the file size down enough so Youtube could go to 480×360 and 30fps and still save bandwidth and output a better quality video!

  • good tutorial matt. I did a screencast recently captured using iShowU and produced with iMovie. I was surprised how difficult it was to get good quality out of iMovie – it took some real tweaking using the advanced settings. i wrote that up here for anyone who is in the same boat -> http://www.scrollinondubs.com/2007/06/12/produce-a-clear-screencast-in-imovie/

    sean

  • 1. Upload video to youtube
    2. Download youtube generated flv file (use videodownloader for example)
    3. Upload flv file downloaded in step 2 to youtube with different name.
    4. Download youtube generated .flv
    5. Do binary compare for files downloaded in steps 2 and 4 and observe that they are identical.

    I think that this proves that it is possible to avoid re-encoding.
    Now you only need to learn how to create .flv file so that it so that it gets through without modifications…

Leave Comment

Commenting Options

Enter your personal information to the left, or sign in with your Facebook account by clicking the button below.

Alternatively, you can create an avatar that will appear whenever you leave a comment on a Gravatar-enabled blog.

bugbugbug