August 25, 2008

 
QuickTime H.264 movies from FCP for the Web

This is a companion article to the Compressor H.264 movies from FCP for the Web.
Some sections of this QuickTime article are the same as in the Compressor article.

By Ken Stone

 
We've all seen Flash videos at YouTube. Flash does an excellent job of reducing long videos into very small files, but there is a price to be paid, the quality of these videos can be very poor indeed. Even with the new 'higher quality' YouTube videos, the quality is not representational of the video that we work with in Final Cut Pro and Final Cut Express. Additionally, YouTube is not the only game in town. Many of us place videos at our own web sites and at other web sites as well. When working in FCP, we struggle to maintain the highest quality video possible. For the web, we need to produce movies that will deliver high quality video.

QuickTime Pro has a codec that will do what we need, deliver high quality video at lower data rates then the codecs that we used in the past. The codec is H.264 (MPEG-4 Part 10) and comes in a variety of flavors. So versatile is the H.264 codec that it is used in a number of different applications. It is used in Blu-ray and the now defunct HD DVD (Toshiba), it is also used by some cable and satellite broadcasters. A number of new video cameras also now use H.264 as an acquisition format. And of course, the topic of this article, for web distribution.

 
Internet Delivery

There are two different methods for delivering your QuickTime movies over the Internet, Progressive and Streaming. Real Time Streaming (RTSP protocol), is used for live events like Internet radio and video. The file is delivered in real time for viewing but is not written to the hard drive. This is one reason for using Internet Streaming, no copy is made. With this type of delivery, the size or bandwidth of the file is critical. If the size or bandwidth of the file is too great, slower internet connections like dial up or slow DSL will have problems playing back in real time. Each Internet Service Provider has different requirements for Internet Streaming, you'll need to check with your ISP for particulars.

Progressive, also known as HTTP download, is downloaded to the viewers hard drive and is not dependent on the speed of the viewers internet connection. The QuickTime movie will start to download and when enough material is in the cache, the movie will start to play. This is called 'Fast Start'. If someone is on dial-up or has a slow connection, then they will have to wait a bit longer for the movie to start. Progressive delivers high quality playback regardless of users' Internet connection speeds. Progressive is much simpler to implement and runs from a standard web server without the need for support from the ISP.

In this article we will be working with Progressive QuickTime movies. While it's true that Progressive is not dependent on the speed of the internet connection, slower connections will have to wait longer before media starts to play, the file size of the QuickTime movie is important. If the file is too big, it will take a long time for the movie to start playing. A large file coming down a slow internet connection could take forever. Even with a high speed internet connection, a very large file could take too long for your viewer to sit there waiting for the movie to begin. So it is important that we create QuickTime movie files that are as small as possible while still maintaining the quality level we desire. Additionally, ISPs charge their users for download bandwidth. If your movie files are extremely large and downloaded often, it could get to be expensive.

 
The FCP Timeline

When we are ready to export our video to H.264 using QuickTime Pro, we'll need to do some testing of different export options to determine the best H.264 export setting. Some people export the entire timeline to QuickTime Pro, but for testing, this process takes way too long and often discourages the user from doing the number of tests required to zero in on the best settings.

Go through your timeline and find a small section of video, 15 to 30 seconds, that presents challenging video to encode, like fast movement of the talent, rapid pans or transitions, which can be very difficult to encode well. Picking difficult video to test with will ensure that all of the video on the timeline will encode well.

Quality vs. File size

There are several different settings in the QuickTime Export Option that control both the quality and file size of the video. It is by making adjustments to these settings that we can arrive at the best combination of settings. The first is choosing a codec and in this case we will be working exclusively with H.264. The next item is the frame size of our output, the height and width of the on screen video. Both the frame rate and keyframe rate play an important role as well. We can further reduce file size by changing the audio export options.

With In and Out points set around our test footage in the timeline, go to the File Menu > Export > QuickTime with Conversion.

This will open the 'Save' dialog box. The first thing I do is enter a name for the export and set Desktop for the destination. We are going to leave the 'Format' as QuickTime Movie. When you first open the export box you'll see that 'Use' is set to 'Default Settings'. Leave this as is, after we do our settings, this will automatically change to 'Most Recent Setting', which is correct.

Click on the Options button which will open the 'Movie Settings' box, shown below with its default settings. It is in this 'Movie Settings' box that we will select all of the QT movie parameters for our export. In the Video section there are two buttons. 'Settings', in which we choose the codec, (in this case H.264) and set its parameters and 'Size' which sets the output dimensions (height and width) of our video. The Sound section will allow us to change the audio settings to help reduce file size. At the bottom of the box is 'Prepare for Internet Streaming'. Even though we are creating Progressive QuickTime movies, we still need to have 'Prepare for Internet Streaming' checked as we need to enable the 'Fast Start' feature for our Progressive movies.

          

 
Video Size Settings
We have all seen numerous movies on the internet and we probably have a good idea of what size we would like our final movie to be, and as the dimensions of the final QuickTime movie has a large impact on file size, I always start my workflow by setting the 'Size' adjustment first.

Back 'in the day', many of us were working with DV-NTSC (PAL) footage in FCP. Since that time, things have become a little bit more complicated in that we now work in a number of different formats and we deal with different dimensioned source files.

And just to keep things interesting, some of the codecs that we now work with, like HDV, AVCHD and DVCPRO HD, use horizontal compression to reduce the size of the files written to tape or card, to save space and reduce bandwidth. So, 1920 x 1080 could actually be 1440 x 1080 or even 1280 x 1080. Now we know that FCP is smart enough to uncompress the horizontal dimension back to full raster for playback (in Real Time), the good news is that QuickTime Pro is equally astute. This is great for us because it means that the dimensions of the source footage does not matter, only the aspect ratio of the format. In the case of all the new HD formats, the aspect ratio is 16:9.

Click on the 'Size' button which will open the 'Export Size Settings' box shown below at default settings.

Clicking on the 'Dimensions drop-down menu we are offered a number of choices. Unfortunately most of these setting won't do us much good. Many are for a 4:3 aspect ratio (we want 16:9) and others are way too large for our intended use of putting movies on the web.

This is okay because we will be using the Custom setting and entering our own sizes. Let's say that I have some HDV video and I want to put the movie on a web page. Remembering that it does not matter if the source footage is 720 or 1080, the fact that it's 16:9 is what counts.

One movie size that I like, has a width of 400 pixels. Using the 400 width, I divide 400 by 16 which comes out to 25. I then multiply 25 times 9 for the height which equals 225. So, the dimensions of my exported QuickTime move will be 400 x 225 and I enter these figures into the Custom Size box. The process is simple, divide your chosen width by 16 and then multiply the results by 9 for the height of your movie.

In the 'Export Size Settings' box shown above, you will note that I have left both the 'Preserve aspect ratio using' and the 'Deinterlace Source Video' boxes unchecked.

Another movie size I find appealing has a width of 480 pixels. I divide 480 pixels by 16 which equals 30, which I then multiply by 9 for my height, which gives me a height of 270 pixels.

Even larger yet, a starting width of 640 pixels. Divided 640 by 16 = 40. 40 times 9 = 360.

If file size and bandwidth is an issue you can go smaller. There is one caveat with the QuickTime player. With different size movies, the QuickTime Player changes size to give a 'wall to wall' output, that is to say that there will be no pillar or letterboxing effects, as you can see from the examples above. If the width of your QuickTime movie goes below 380 pixels, when you view the movie on your desktop you will see pillar boxing, shown below left. Don't worry, this is an issue with the QuickTime Player, there is nothing wrong with your movie and once the movie is embedded in your web page and view on the internet, the QuickTime Player will display the movie properly as shown below, right, which is an actual embedded 2 second clip (go ahead and click on the Play button).


Screen shot of the QuickTime Player
on the Desktop showing pillar boxing.

Once the QuickTime movie has been Embedded into a web
page, the movie is displayed properly with no pillar boxing.

 
When working with DV NTSC, 720 x 480, we need to remember that Standard Def. digital video uses rectangular pixels, the pixels are taller than wide. However, we will be viewing the finished QT movies from the internet on a computer screen and computers use square pixels. The outcome of this would be that the video in the finished QT movie, when displayed on a computer screen, would show some distortion. The images would be slightly squished down. Although DV does not show correctly in QT, because it is meant for display in a non square pixel environment, H.264 is able to playback these pixels correctly on a square pixel display. You can use a 4x3 or 3x2 aspect ratio for picking frame sizes, whichever is most convenient.

Here are some suggested 4x3 frame sizes. You can create your own dimensions by picking a width and dividing the width by 4 and multiplying the results by 3.

  • 160 x 120
  • 240 x 180
  • 320 x 240
  • 360 x 270
  • 400 x 300
  • 480 x 360
  • 640 x 480

        

 
A few last thoughts about the dimensions of your exported QuickTime movie. When you are doing the math, both the width and height of your exported movie must be whole numbers, the QuickTime 'Export Size Settings' box does not accept fractions. So, while 400 pixels is okay, 400 divided by 16 = 25, a width of 420 will not work because 420 divided by 16 = 26.25 and 26.25 multiplied by 9 = 236.25. As long as your width, when divided by 16, comes out as a whole number, then the hight, determined by multiplying by 9, will always be a whole number too. I hope you are following my drift.

If you speak with professional encoders they will tell you that when working with H.264, both the height and width dimensions must be divisible by 8. This is because the H.264 encoder works in blocks of 8. However, when working with sizes that are appropriate for web pages, you'll be hard pressed to find many sizes that have an aspect ratio of 16:9, where both the height and width are divisible by 8. If your dimensions are not divisible by 8, it might mean that the displaying render engine has to work a little harder to play back your QuickTime movie, but there should be no ill effects. I checked a number of H.264 QuickTime movies on the web and none of them have dimensions that are divisible by 8.

 
Video Settings
With the output dimensions set for our QuickTime movie, it's time to turn to working with the H.264 codec. Back in the 'Movie Settings' box, in the 'Video' section, click on 'Settings'.

This will open the 'Standard VIdeo Compression Settings' window, shown below at default settings. Yes, the QuickTime default is now the H.264 codec.

Click on the 'Compression Type' drop down menu and you will see that all codecs offered by FCP are offered here. If H.264 is not selected, select it.

There are three sections, Motion, Data Rate and Compressor, that control the finished file size and the playback quality of our QuickTime movie. The Motion section is shown below at default.

First on my list is to find a good frame rate for the export. Lowering the frame fate, the number of frames displayed every second, will cut file size. The frame rate that you choose will depend on the amount and speed of motion in your video. If your video is of 'talking heads', then you will be able to lower the frame rate by a large amount. On the other hand, if your video is of a Baseball game, which can have some fast motion, the amount that you can reduce the frame rate will be limited. So some testing is in order. Before you pick a trial frame rate, set 'Key Frames' to automatic, we'll talk about this in a minute.

The video I'm working with is DVCPRO HD 1080i 60, which means that it has a frame rate of 29.97. For my first test I am going to start with a frame rate of 15 frames per second. After export, open the movie in QuickTime and play. How does the video look? Does the motion look smooth or choppy? If the motion looks good, you can go back and reduce the frame further, to say 12 frames per second. Now, how does this playback? The idea of this testing is to continue to lower the frame rate until you get poor results. Once you hit an unacceptable frame rate, go back to the next higher frame rate where the motion still looked good. This will be your frame rate. It might sound like a bit of a chore doing all of this testing, but the good thing is that QuickTime will remember your last settings, so when testing, you only need to change the one parameter that you are currently working with, the other settings will hold. If you quit FCP the QuickTime settings will return to default the next time you launch FCP.

        

I mentioned above to set the Key Frames to Automatic. The keyframe lies at the heart of compression and has everything to do with the output quality of our QuickTime movie. The flavor of H.264 that we are using is an Interframe codec, using Temporal compression, which means that it works with groups of pictures or GOPs (often 15 frames in a group). The H.264 codec is able to compress, reduce the size of a file, by taking one frame of full video information and then generating the next number of frames by storing only the differences between each frame and the first full image frame. By storing only the changed information, the file becomes much smaller. This first frame is called a 'keyframe' or 'I' frame.

In the past, with older codecs, we could enter values for how often a keyframe is created. However, if we set this parameter to 'Automatic', we will let QuickTime determine the optimal keyframe rate (file sizes vs quality) based on the video it is working with. I have found that using 'Automatic' works very well.

The last item in the Motion section is 'Frame Reordering'. 'Frame Reordering' can help improve the quality of the finished movie, but it is processor intensive. For our intended destination of the web, this is not an issue. If you are creating QuickTime movies for the iPhone or ATV, which have less processing power than our Macs, you would want to uncheck the 'Frame Reordering' box.

The two other two sections are 'Data Rate' and 'Compressor Quality'. While these are two different parameters, they are linked together. When Data Rate is set to Automatic, QuickTime will determine the best data rate (quality vs. file size) based on where you set the Quality slider. You will note that when Automatic is selected, that the Quality slider, in the 'Compressor' section, is active.

Selecting 'Restrict to' rather than Automatic allows you to enter specific bandwidth amounts and would be used when you plan to stream your movie from a streaming server. Internet Streaming is used for live web cast, internet radio shows, or the radio stations found in iTunes. Internet Steaming is different from the common QT downloads that most of us use. If you are not creating Streaming QT movies, and most will not be, leave this setting at the default, Automatic. As shown below, when 'Restrict to' is selected in the Data Rate section, the Quality slider in the Compressor' section becomes grayed out and is not available.

With our frames size and frame rate established and the Data Rate set to Automatic we can now move to the Compressor section where we can use the Quality slider. Obviously, the Quality slider allows us to adjust the quality of the encode and thus further control the file size. We will test the Quality setting in the same way that we tested the frame rate. Export the short QuickTime test movie and check the quality. If it looks good, move the Quality slider down and test again. Continue until you find the lowest quality setting that the video still looks good. Most often you'll find that a setting in the area of Medium will work well.

At the bottom of the Compressor section you will see encode settings for Multi-pass and Single-pass. Selecting Multi-pass allows QuickTime to run a first pass in which it will evaluate the video and a second pass to encode using information gathered in the first pass. Multi-pass will produces better quality video at the same file size, but the process does take longer than Single-pass.

 
Sound
The Sound section in the 'Movie Settings' box allows us to adjust the audio settings to further reduce the file size of out movie. Changing the audio settings can have a large impact on file size. Click on the Settings button to open the Sound Settings window, below right at default settings.

           

You can leave these settings as is for maximum sound quality, but it might be a bit of 'over kill' for our computer speakers and will do nothing to reduce the audio file size. How you adjust these settings depends on the audio in your movie. If the movie contains a lot of dialog or maybe concert music, you might want to make small adjustments to the audio settings. If the audio is not that critical, like background music or ambient sound, then you can further reduce the audio settings for a smaller file.

The AAC encoder found In the 'Format' drop down menu is a good choice. Depending on your audio you can select Mono over Stereo to reduce the file size.

           

The next setting is 'Rate' or audio sample rate. The native audio sample rate for FCP is 48k, but remembering that the audio sample rate of audio CDs is 44.1k, this might be a good choice. You can choose 32k for smaller size, again, depending on your audio.

The Render section follows and generally you can leave the settings in the 'Render' section at their default, shown below. For audiophiles you can move up the Render Quality, additionally you can increase the Target Bit Rate setting up to improve audio quality.

In the Sound Settings window, at the bottom, is a Preview feature for you to test out your audio settings, (no need to export the movie to audition the audio). If you place a check in the 'Play Source' box you can listen to the source file for comparison. A very nice feature.

 
Save
When you have finished testing and have decided on your QuickTime movie dimensions (height and width), Codec and Audio settings and are 'good to go', you will, of course, need to return to FCP and either set In and Out points on the timeline for your entire movie, or select the Sequence in the Browser. Export QuickTime with Conversion and return to the 'Movie Settings' window, a summary will be presented. This is a good chance to review your final settings before you export. You may want to take notes (a screen shot) of your finial settings.

Name your movie in the 'Save' dialog box and save it to the Desktop. "Format" should be QuickTime Movie. You will notice that the "Use" box now reads 'Most Recent Settings,' this is correct and it is referring to the settings that you just completed.

When I wrote an article about exporting QuickTime (Sorenson) movies for the web over four years ago, I lamented the fact that there was no way to 'Save' the finished QuickTime settings for future use. Over four years have passed and this feature is still missing, a real short coming for a "Pro" app. If you want to save your finalized QuickTime settings, I would suggest that you take a screen shot (command-shift-4 from the keyboard) of your 'Movie Settings' window and put it away somewhere for future reference.

 
Gamma Correction
In the days before the introduction of H.264, Sorenson was my codec of choice. One of the most frustrating issues of using Sorenson is that while the exported QuickTime Sorenson movie might look great on a Mac, when this same QuickTime movie was played back on a PC, the movie looked too dark. This is because the basic 'Gamma' output is different on Macs and PCs. H.264 is a much more intelligent codec, as the H.264 codec automatically buries 'Color Sync' profiles in the QuickTime movies. At playback, the H.264 QuickTime movie will check the platform of the viewer and adjust gamma automatically, serving up a gamma corrected version for that platform, Mac or PC. This is a powerful feature.

 
Final Thoughts
I mention that Progressive QuickTime movies are downloaded to your hard drive, but you will not be able to locate it in the Finder, you'll need to save it first. To save a copy of the movie, once it has completed the download, control or right click on the movie and select 'Save As QuickTime Movie', you will then be asked where to save it. Saving will happen almost instantly as the file is already on your hard drive.

       

Remember that it's not the dimensions or format of your source file, even ProRes 422 works well, but rather the displayed aspect ratio of your source video. So even if your HD footage has horizontal compression, 1440 x 1080, it will display at 1920 x 1080, your aspect ratio is 16:9.

Producing good QuickTime movies for the web is a bit of a black art. There are a number of ways to reduce the size of a QuickTime movie but it comes at a price, quality. Testing is a must. I often will build a number of QuickTime test movies (you should see my desktop), changing parameters as I go, trying to get that 'right' combination of quality and size.

 
Enjoy,

--ken

 
[Top]

copyright © www.kenstone.net 2008

© 2000 -2008 Ken Stone. All rights reserved. Apple, the Apple logo, Final Cut Pro, Macintosh and Power Mac
are either registered trademarks or trademarks of Apple. Other company and product names may be trademarks of their respective owners.

All screen captures, images, and textual references are the property and trademark of their creators/owners/publishers.