Tutorial: Encoding H.264 Video in Adobe Media Encoder CS5.5 and Apple Compressor 4
If you’re a streaming producer you have to know how to produce H.264 for both Flash distribution and for mobile devices. Fortunately, Adobe Media Encoder makes this simple with multiple presets for desktop and mobile players which I’ll show you how to find and customize in this tutorial. If you’re coming over from Final Cut Pro 7 and Compressor, you’ll be happy to know that Adobe Media Encoder is much easier to use than Compressor, encodes faster, and produces much higher quality output, as you can see in the video that accompanies this article.
Encoding Sequences from Premiere Pro
So let’s start our look at Adobe Media Encoder in Premiere Pro, which is the application from which you’ll access Adobe Media Encoder most of the time. To encode a sequence in Adobe Media Encoder, you choose a sequence to export and then select File > Export > Media. The Export Settings window opens (Figure 1, below)
Premiere Pro’s Export Settings window
Choosing H.264 Formats
Any time you’re going to work in the Export Settings window, you should start by choosing a format. If you’re producing H.264 for streaming, there are two formats that you should consider. The first, H.264, is for general-purpose H.264 output including iPod and iPhone as well as exporting for UGC upload, with Vimeo and YouTube presets available at the bottom of the drop-down list box (Figure 2, below).
Figure 2. General-purpose H.264 Export Settings options
If you’re producing for Flash, there’s an F4V export option; there are also options for exporting for Blu-ray. One of the nice things about Adobe Media Encoder is that it supports a lot of different export formats. You’ve got FLV, you’ve got P2, you’ve got MXF—in short, a lot more export presets than you do with Compressor 4, and a lot more formats you can access without buying a plugin or using a separate tool.
Choosing Encoding Presets
After you’ve chosen your format, you choose your preset. The video used in this tutorial is a clip shot at Streaming Media West that I’m editing for upload to OnlineVideo.net. Because I’ve shot and encoded clips for OnlineVideo.net in the past, I’ve got two different custom presets customized for the site, which you can see at the top of the pull-down in Figure 2. One is for video and the other is for screencams.
Because I have a custom preset already available that I can use to encode this clip for the target site, all I have to do is choose this custom preset and then click the Queue button at the bottom of the Export Settings dialog. This will send the file to Adobe Media Encoder, which is what you’ll do most of the time. Alternatively, you can choose Export, which will export the encoded file directly from Premiere Pro (using the same encoding engine), but will lock up Premiere Pro during the Export period.
Working in the Adobe Media Encoder Interface
In most cases, you’ll want to choose Queue and launch Adobe Media Encoder (AME), whether it’s to give you more oversight of the encoding process or to keep the encode from interrupting your editing workflow in Premiere Pro (or both).
AME’s Queue Window
Figure 3 (below) shows Adobe Media Encoder’s three-window interface. On top is the Queue window, which shows you the files that are queued for encoding, with columns for the format, the preset, and the output file.
Figure 3. Adobe Media Encoder’s 3-window interface with the Queue window on top
AME’s Current Encode Window
Below the Queue window is the Current Encode window Figure 4 (below). You begin encoding files in this window by clicking Start Queue. Once your files start encoding, you’ll be able to see the files’ encoding progress in this window. If there are any obvious mismatches for aspect ratio, or if you see letterboxing or anything like that, watching the encoding process in this window gives you an opportunity to spot the problem before the encode is done. This is a nice feature that will save you some time every once a while when you do make a mistake.
Figure 4. AME’s Current Encode window
The Watch Folder Window
Below the Current Encode window is the Watch folder window. Compressor 4 also supports watch folders, but only if you know how to create and manage them via Apple script; Adobe Media Encoder, by contrast, supports watch folders in the interface itself.
Figure 5 (below) shows a single watch folder that I’ve set up to produce 5 separate files for adaptive streaming, so that if, at any time, I want to produce these files, I just drop the source file into a single watch folder and AME will encode all 5 of these files. This is a very convenient function if you’re producing for adaptive streaming.
Figure 5. A Watch folder in AME CS5.5
Customizing H.264 Encoding Presets
So that’s the overview; now let’s get into customizing your presets for H.264 encoding. If you click on a preset in the Preset column of the Queue section at the top of the interface, the Export Settings dialog opens once again. We’ve seen this before when exporting from Premiere Pro. Here you’ll see five tabs that control the basic options in the encoding interface.
The Filters Tab
The first tab on the left is the Filters tab. One filter that will be familiar in name and function to Final Cut users is the Gaussian Blur filter (Figure 6, below). If you’ve got very noisy video, you might want to try applying the Gaussian Blur at the encode stage (if not before).
Figure 6. The Gaussian Blur filter
The Multiplexer Tab
The Multiplexer tab (Figure 7, below) is where you customize the multiplex settings for 3GPP (cell phone use), MP4 (general-purpose MP4 use), and None, which is separate audio and video files. If you do choose MP4, you’ve got 3 options to choose from. First is Standard, which includes upload to You Tube, upload to UGC sites, and general-purpose H.264 production. You’ve also got PSP, which provides stream compatibility that you can set for Play Station Portable, and the third option, iPod.
Figure 7. The Multiplexer tab
The Audio tab
In the Audio tab you’ll find typical parameters. First you choose your codec. Your choices include AAC, AAC+ Version 1, and AAC+ Version 2 (Figure 8, below). Typically, I’ll use just AAC because it’s the most broadly compatible.
Figure 8. Codec choices in the Audio tab
Output Channels choices include Mono, Stereo, and 5.1. You can also choose an Audio Quality setting–Low, Medium, or High—although that typically has no effect because the bit rate controls the quality.
You choose your bit rate in the Bit Rate Settings field below. You can also choose whether bit rate has precedence over frequency, which is typically the option that I select.
The FTP Tab
In the FTP tab, if you’re producing a file that you want to upload to a remote location via FTP after the encoding is completed, just select the checkbox shown in Figure 9 (below), fill in the credentials, and Adobe Media Encoder will upload the file to that FTP site once encoding is complete.
Figure 9. The FTP tab
The Video Tab
So let’s come back to the Video tab, which is where you do most of the heavy lifting when you’re encoding video (Figure 10, below). The first thing you’ll notice is that Adobe uses the MainConcept H.264 video codec, and that’s true for both H.264 production and H.264 production for Flash. That’s important because it’s much higher quality than the Apple codec that Apple uses in Compressor and we’ll see some examples of that later in the tutorial.
Figure 10. The Video tab
A lot of this stuff is going to look pretty standard if you’ve produced compressed video before: You’ve got your resolution, you’ve got your frame rate, and field order. All streaming files are progressive, so you can just leave the Field Order setting at the default Progressive (None).
Then you’ve got your aspect ratio. This is a 16:9 file that we’re using in this example, so Widescreen 16:9 is the right option. When I’m encoding files with the Adobe Media Encoder I toggle back and forth between the Source and Output windows because if there is a mismatch between the source file and that output pixel aspect ratio, it’ll show up here in the black bars (Figure 11, below).
Figure 11. The black bars in the video window indicate a mismatch between the source file and the output pixel aspect ratio.
So toggle this back and forth and then you can set the Pixel Aspect Ratio field to Square Pixels or you can set it for Widescreen 16:9. Both work, and you’ll know that it works when you toggle back and forth between Source and Output because there will be no black bars or other issues.
Profile and Level
Now let’s come back to Profile and Level, which are the two H.264 encoding parameters you can access directly in this interface (Figure 12, here). Typically you won’t select the Render at Maximum depth, because it doesn’t add any quality, and it takes a little bit more time.
Figure 12. Profile and Level, the two H.264 encoding parameters you can set in the Video tab
Bitrate Encoding Settings
Figure 13 (below) shows your Bit Rate Encoding Settings. For most general purpose encoding, you’re going to want to choose VBR, 2 Pass. If you’re encoding for adaptive streaming or encoding for limited-bit rate connections such as cellular, you may want to use CBR. If you choose VBR, 2 Pass, you can choose your target data rate, which we have at 6Mbps (six megabits per second) in Figure 13.
Figure 13. Choosing VBR, 2 Pass, 6Mbps for video encoding
With VBR (which stands for variable bit rate), you can also set the maximum bit rate. Typically I’ll set that at twice the target, so in this case I’d choose 12. If you want to set the keyframe distance (the interval between key frames in which the VBR encoder assesses and sets a bit rate), you select the Set Keyframe Distance checkbox, and then you can put in any interval that you want. Typically, when I’m producing for streaming or for upload, I’ll use 300 frames, which is 10 seconds with a 29.97 file.
At the bottom of the screen, selecting Maximum Render Quality, which will produce the maximum quality. It could cost you in encoding time, but not so much if you’ve got an NVIDIA CUDA card in your system, which I recommend for all CS5.5 production.
You would select the Use Frame Blending checkbox if you changed the frame rate between the source and the output footage. We didn’t do that with this clip. If you’ve previewed your video on a timeline, you might want to choose Use Previews, which could speed encoding time by using previews that were produced in the Premiere Pro. Again, we didn’t do that with this clip so that’s not an issue.
Next, let’s come back to the H.264 parameters. First, we’ll look at encoding profiles. Your choices include Baseline, Main, and High. As we’ll see, you can choose only Main or Baseline in Compressor 4, and that’s probably one of the reasons that the quality isn’t as good in Compressor as what you get with the Adobe Media Encoder.
When I’m producing for computer playback of online video, typically I’ll use the High Profile. I don’t really care about Level in this scenario because that’s not relevant when you’re producing for computer playback.
If you’re producing for mobile device playback then you typically want to let Adobe Media Encoder choose the profile and the level (Figure 14, below). With mobile delivery, you don’t want to adjust the profile or level because if you do adjust them and you take the encoded video out of spec for the targeted device, the file may not load or it may not play.
Figure 14. When encoding for mobile devices, let AME pick the level.
Let’s come back to the preset that I was using for OnlineVideo.net. Figure 15 shows the profile and level that I have set for this particular file.
Figure 15. Encoding settings (including Profile and Level) for the file we’re encoding with our OnlineVideo.net presets
Entropy Encoding and B-Frames
How does Adobe Media Encoder handle entropy encoding and B frames, which are two pretty critical parameters to H.264 encoding? The chart in Figure 16, below illustrates that.
Figure 16. Profile-Dependent Entropy Encoding and B-Frames
For most H.264 encoding, the profile that you choose controls both entropy coding and B-Frames. So if you choose the Baseline profile, you use CAVLC as opposed to CABAC, and you have no B-Frames. That makes sense because the Baseline profile can’t handle CAVLC or B-Frames. If you encode using the Main Profile, Adobe Media Encoder uses CABAC entropy coding and inserts 3 B-Frames. If you use the High Profile, it also uses CABAC, but it uses the two B-Frames.
The only exception to this is when you’re producing for Apple i-devices. If you produce in this configuration, Adobe Media Encoder will always use CAVLC and will not insert any B-Frames into the compressed stream. All other configurations let the selected profile control whether you use B-Frames and which version of entropy coding.
Saving a New Custom Preset
Now we’ve set our parameters. If you want to save the parameters you’ve chosen for a given clip as a preset, click the Save Preset button shown in Figure 17. The Choose Name dialog opens, and there you can name your new preset. Then next time you want to encode to these parameters, or any other saved custom presets, all custom presets will appear above the presets that come with the product itself.
Figure 17. Selecting Save Preset to the right of the Preset field in the Encode Settings window
Apple Compressor 4
So, compared to Apple Compressor 4—the version of Compressor that became available the same week as Final Cut Pro X—Adobe Media Encoder is a lot easier to use. As you can see Compressor uses different interfaces for mobile and desktop encoding (Figure 18, below). It doesn’t support the high profile, and it makes you work through three different screens to set your video encoding parameters.
Figure 18. Apple Compressor 4
Compressor is also slower than the Adobe Media Encoder. It encoded our test file in 7 minutes and 10 seconds compared to the Adobe Media Encoder, which produced the same file in 4 minutes and 17 seconds. Compressor's quality is also much lower, as you can see in the side-by-side comparisons in Figure 19 (below) and 20 (below).
Figures 19 and 20. Two side-by-side comparisons of encoded video quality in Apple Compressor and Adobe Media Encoder
Even in this low motion video footage you can see that there’s slightly more detail in the images on the right, and in the second set of images you can also see the start of fading in the shirt in the Compressor footage.
In the higher-motion clips shown in Figure 21 (below), again in the Compressor footage you see loss of detail, you see no pinstripes in the image on the left (Compressor) while they’re obvious in the image on the right (Adobe Media Encoder), and you’re starting to see a lot of fading in the Compressor footage.
Figure 21. Higher-motion footage comparison
As we get into higher- and higher-motion video, such as the footage that yielded the screenshots in Figures 22 and 23 (below), you’re going to see even more evidence of that. You see much more detail in the face in the Adobe Media Encoder version than the Compressor version, much more detail, and very usable quality for the Adobe Media Encoder where the image is obviously faded with almost complete loss of detail for Compressor.
Figures 22 and 23. High-motion ballet footage comparison
So now you know how to choose and customize H.264-related presets in the Adobe Media Encoder. You’ve also seen that Adobe Media Encoder is faster and produces higher-quality output than Apple Compressor 4.