AfterDawn Blu-ray Encoding Tutorial


AfterDawn Blu-ray Encoding Tutorial Lesson 4
Encode Video

Over the course of the first three lessons of the Blu-ray Encoding Tutorial you analyzed, opened, and edited your source videos, as well as determining chapter points and calculating the bitrate to encode at. With all that prep work completed, you will now encode your video. When you are finished you will have a H.264 (MPEG-4 AVC) video file which meets all the requirements for Blu-ray compatibility and is ready for authoring in the application of your choice.

The Complete AfterDawn Blu-ray Encoding Tutorial

Encoding video for Blu-ray is easy, but not necessarily simple. To make it easier to learn we have divided this tutorial into several individual lessons, each of which addresses a single step in the process. At the top and bottom of each lesson is a navigation menu where you can jump to any other lesson in the series. You can easily return to a previous section for review or skip over any future section. It is recommended that you read the entire series at least the first time through.

Lesson 1 - Prepare Source Video

In the first lesson you will learn how to analyze your source video, ensuring AviSynth will be able to decode it properly, and also formulate a plan for making any changes which may be required. In most cases this will also involve creating an index, which is a sort of map to the contents of a video.

Lesson 2 - Create AviSynth Script

In the second lesson you will learn to use MeGUI's AVS Script Creator tool to provide instructions for loading your source video and performing any required processing. This may include resizing video to the desired resolution and either deinterlacing or bobbing interlaced video to make it progressive.

Lesson 3 - Create Chapter File and Calculate Bitrate

In lesson three you wil learn how to create a file specifying chapter points and calculate the correct bitrate for your encoded video.

Lesson 4 - Encode Video

In lesson four you will learn about the proper settings for encoding your video.

Lesson 5 - Encode AC-3 Audio

In lesson five you will learn how to encode your audio to AC-3 format using MeGUI and either the Aften encoder or FFmpeg. When you complete this step you will have Blu-ray compliant audio files.

Lesson 6 - Advanced Bitrate Calculation

In lesson six you will learn more advanced techniques for calculating bitrate when you are authoring a Blu-ray disc from multiple video files.

Lesson 7 - Advanced Audio Processing

In this lesson you will learn how to use Audacity to combine individual audio files to produce either an uncompressed (LPCM) or Dolby Digital (AC-3) audio stream

Lesson 8 - Convert Text Subtitles To Images

In Lesson 9 you will become familiar with the process of converting subitles from the text-based SRT, SSA, and ASS formats to Blu-ray compliant SUP or BDN XML format.

Lesson 9 - Prepare A Still Menu Background

After completing Lesson 10 you should be able to create a single frame video file for use as the background for a Blu-ray still menu. You will also be able to extract a video frame as a regular still image file (such as a PNG or JPEG) and how to convert those common files into single frame, Blu-ray compliant video streams.

Lesson 10 - Make Menu Buttons With GIMP

This lesson will teach you the basics of making your own buttons for Blu-ray menus using the free image editor GIMP. It also includes tips on how to add elements necessary for a functional Blu-ray menu to a still image and assemble a mockup so you know what your menu will look like before you start the authoring process.

Official AfterDawn Blu-ray Encoding Tutorial feedback thread

We have created a dedicated discussion in our forums (open in new window) for feedback on this tutorial. We would love to hear your whatever thoughts you have. Tell us what you liked or what you didn't like. Let us know if there was something you didn't understand or even something that was just plain wrong. We strive for 100 percent accuracy in our guides, but nobody's perfect. Any help you can give us in getting a little closer to that goal is appreciated. Our goal is to help you out, and anything we can change to do a better job of that is an improvement.

Lesson 4 Objectives

  • Create a generic Blu-ray encoding profile which includes all the required settings for the video you are encoding
  • Create a second profile based on those generic settings which you can customize with settings specific to your video file
  • Customize this second profile with the chapter and bitrate information from Lesson 3
  • Create an encoding job and encode your video to Blu-ray compliant H.264

BDMV, the format used for Blu-ray authoring, allows a number of different combinations of resolutions and framerates. In addition, some trickery on x264's part allows you to expand those options to fill in some glaring gaps, such as progressive video running at either 25 or 29.97 frames per second. The sections covering the settings which enable these features will include notes explaining further.

Some Explanation Of Video File Notation

A common point of confusion, and not just in the Blu-ray world, is the often inexact naming convention used to describe the combination of resolution and framerate for a particular video file. Typically this is given as a sequence of a number representing the video's vertical resolution followed by either p or i representing progressive or interlaced which is followed by a number representing the framerate. For example, 720p50 describes video with a resolution of 1280x720 which is progressive and plays at 50 frames per second (fps).

However, it's not always that straight forward. Take, for example, 1080p24. Just in the context of Blu-ray you have the following possibilities. The resolution could be 1920x1080 or 1440x1080 (which is stretched to 1920x1080 on playback). Additionally, 24 may refer to 24fps, the traditional film framerate, or 23.976fps which is a framerate film is slowed to for compatibility with North American (NTSC) analog TV. In fact, the only bit in that description you can be sure about is that it's progressive. Likewise, 720p30 may refer to video running at 30fps or 29.97fps, once again a NTSC-based framerate and 720p60 may be 60fps or 59.94fps video.

For the purposes of this tutorial we will simplify things significantly. As a result of the need to work with legacy (analog) NTSC displays, because the BDMV standard is relatively limited when it comes to framerates. If, in this guide, you see a reference to a framerate of 30fps or 60fps you can interpret it to mean 29.97fps or 59.94fps respectively. The exception will be references to 24fps video, such as 720p24 or 1080p24.

Since both 24fps and 23.976fps video is allowed by the BDMV standard, this may refer to either. At least for the purposes of this guide (video encoding) there is no practical difference. The settings for both will be identical so there is no need to distinguish between them.

Unless otherwise specified, the video formats listed here refer to your source AVS file (AviSynth Script) and not the output. I have organized things this way because different input properties will often require different settings to produce a file with essentially the same properties. For example, 720p30 and 720p60 sources will both be encoded to play at 720p60, but one will require frame doubling while the other will not. By separating them into separate sections I have hopefully simplified the process of determining the correct settings for you.

Quick Links To Settings

In order to make this lesson equally useful as a reference source once you are familar with the process involved, this table will take you directly to the appropriate settings for your video. Simply look in the column where your video's resolution and frame type (progresive or interlaced) is listed and click on the framerate. This will take you directly to the settings you will need for that particular source.

1920x1080 or 1440x1080 1280x720
Progressive Interlaced Progressive
23.976fps 23.976fps
24fps 24fps
25fps 25fps 25fps
29.97fps 29.97fps 29.97fps

Opening The x264 Encoder Settings

Unlike the other tools you have used to this point, the video encoder settings can be accessed directly from the main MeGUI window.

Opening MeGUI's x264 encoder settings -

1. Profile Selection

Make sure a x264 profile is selected from this list. If this is the first time you have opened the video encoder settings this will be called scratchpad.

2. Open Video Encoder Settings

Click this button to open the encoder settings dialog.

Encoder Profiles

The first time you open the x264 Settings you will be presented with some generic settings. Although you could immediately begin setting up your video encoding job, it's better to start by creating at least one generic Blu-ray profile which you can then copy to create each encoding job. By doing this you will save yourself the trouble of changing the necessary options every time you encode another video. If a bitrate has automatically been entered for you, you should make a note of it somewhere so you can use it later without repeating work you have already done in the Bitrate Calculator.

Create a new x264 profile in MeGUI -

Use the New button to copy the settings from the currently selected profile to your new profile. You will immediately be prompted to give it a name.

Name a new MeGUI x264 profile -

1. Profile Name

You can name your profile anything you'd like. I'm using a description of the source files it is intended for..

2. Create Profile

Once you click OK your new profile will be created

Common Settings

Regardless of your source, there are some common settings you should consider. Most are optional, but others are mandatory if you want to create Blu-ray compliant video files.

MeGUI Blu-ray encoding settings on the Main tab -

1. Target Playback Device

This must be set to Blu-ray play to enable x264's internal BDMV compatibility settings.

2. Advanced Settings

This box must be checked so you can set some additional options required for Blu-ray compatibility.

3. Preset

This slider chooses a x264 Preset for encoding. Drag it to the right for higher quality, but slower, encodes. Drag it to the left for faster, but lower quality encoding. Generally speaking it's best to adjust this as far to the right as you can stand, which basically means until encoding slows down too much. Don't go as far as Placebo, though, since it will be incredibly slow but likely offer no quality gain over Very Slow. Also make sure to avoid Ultra Fast.

4. Tuning

Tuning provides optimzations for particular types of footage. In most cases Default will give you the best results. Since you are making this initial profile as a default to copy from rather than for a specific video, this should probably be left at Default unless the majority of video you encode is better suited to a particular Tuning. Despite the name, Film Tuning is often not the best choice for film sources.

5. Encoding Mode

Once you check the box to show the Advanced Settings, several new options will appear in this list. Make sure Automated 2pass is selected.

6. Average Bitrate

This is the average bitrate to use for encoding. Once again, keep in mind this is a default profile which you will probably not be using directly to encode so the bitrate you enter may never actually be used for encoding.

Additional Settings Based on Source Properties

Below you will find settings for various combinations of resolution, frame type, and framerate. Simply scroll down until you see the combination which matches your source video and follow the instructions. Some options must be set for every type of source while others are specific to a particular property such as interlacing. You can also use the table above to jump directly to the proper settings based on the resolution, frame type (interlaced or progressive) and framerate of your source video.


For practical purposes you can think of these both as 1080p24, which is also how they are generally described by most people anyway. This is the combination used for most studio releases because it provides the greatest resolution at the native framerate of film and standard digital cinema.

Frame-Type Tab

Setting a 1 second GOP length for Blu-ray in MeGUI -

Set maximum GOP length to 1 second

Maximum GOP Size should be set to 24 so it is no more than 1 second of video.

Misc Tab

Set x264 SAR to 1:1 in MeGUI -

Set Sample Aspect Ratio

Force SAR must be set to 1:1 if the resolution is 1920x1080 or 4:3 if it is 1440x1080.

1080p25 & 1080p30

Although Blu-ray technically doesn't allow 1080p video at these framerates, it does allow 1080i. Thanks to some advanced features which allow partially and entirely progressive frames in an interlaced video stream1, x264 can encode this type of video progressively while still maintaining Blu-ray compatibility.

1 This is possible because H.264 includes special types of interlaced streams which may also contain frames which are either partly or entirely progressive. This setting simply produces such a stream where all the frames are progressive, which is the same thing to a Blu-ray player.

Frame-Type Tab

Setting a 1 second GOP length for Blu-ray in MeGUI -

Set maximum GOP length to 1 second

Maximum GOP Size should be set to 25 for 25fps video or 30 for 29.97fps so each GOP lasts no more than 1 second.

Analysis Tab

Set Fake Interlaced option for Blu-ray encoding in MeGUI -

Output interlaced stream with progressive video

Check this to produce a Blu-ray compliant interlaced stream with 100% progressive frames.

Misc Tab

Set x264 SAR to 1:1 in MeGUI -

Set Sample Aspect Ratio

Force SAR must be set to 1:1 if the resolution is 1920x1080 or 4:3 if it is 1440x1080.

1080i25 & 1080i30

Whenever you encode interlaced video you need to make sure you know the correct field order. Either to top or bottom field must be set to display first. Get it wrong and the picture will appear jerky. You should already have this information by the time you get done in the AVS Script Creator. If not, you should go back to Lesson 2 for help figuring it out.

Frame-Type Tab

Setting a 1 second GOP length for Blu-ray in MeGUI -

Set maximum GOP length to 1 second

Maximum GOP Size should be set to 25 for 25fps video or 30 for 29.97fps so each GOP lasts no more than 1 second.

Set the field order for interlaced x264 encoding in MeGUI -

Set the field order

Set the field order for your interlaced video. If the top field should be displayed first select TFF (Top Field First). If the bottom field comes before the top select BFF.

Misc Tab

Set x264 SAR to 1:1 in MeGUI -

Set Sample Aspect Ratio

Force SAR must be set to 1:1 if the resolution is 1920x1080 or 4:3 if it is 1440x1080.


Being primarily designed for distributing professionally produced content, and much of that content originating from film source, Blu-ray allows both 720p at 24fps or 23.976fps.

Frame-Type Tab

Setting a 1 second GOP length for Blu-ray in MeGUI -

Set maximum GOP length to 1 second

Maximum GOP Size should be set to 24 so it is no more than 1 second of video.

Misc Tab

Set x264 SAR to 1:1 in MeGUI -

Set Sample Aspect Ratio

Since 720p video always has a resolution of 1280x720, Force SAR should always be set to 1:1.

720p25 & 720p30

Although 720p video is technically required to have a framerate of either 24fps, 50fps, or 60fps, x264 is able to produce a stream which is encoded at 25fps or 30fps but displays each frame twice, effectively doubling the framerate to the higher, Blu-ray compliant, framerates.

Frame-Type Tab

Setting a 1 second GOP length for Blu-ray in MeGUI -

Set maximum GOP length to 1 second

Maximum GOP Size should be set to 25 for a 25fps source or 30 for 30fps so each GOP lasts no more than 1 second. Even though the video will display twice as many frames, only half that many will be encoded.

Set frame doubling pulldown in x264 in MeGUI -

Set Pulldown to double

Select double from this dropdown. This tells x264 to display each frame twice, allowing you to duplicate every frame to produce a Blu-ray compliant stream without wasting extra bits required to actually encode the extra frames.

Misc Tab

Set x264 SAR to 1:1 in MeGUI -

Set Sample Aspect Ratio

Since 720p video always has a resolution of 1280x720, Force SAR should always be set to 1:1.

720p50 & 720p60

Aside from 24fps, these are the only framerates which are technically allowed for 720p video.

Frame-Type Tab

Setting a 1 second GOP length for 60fps Blu-ray video in MeGUI -

Set maximum GOP length to 1 second

Maximum GOP Size should be set to 50 for a 50fps source or 60 for 60fps so each GOP lasts no more than 1 second.

Misc Tab

Set x264 SAR to 1:1 in MeGUI -

Set Sample Aspect Ratio

Since 720p video always has a resolution of 1280x720, Force SAR should always be set to 1:1.

Create A New Profile For Your Video

At this point you should have a generic profile based on the resolution, frame type, and framerate of your video file. Now you will create a second profile specifically for a single encoding job, copying the settings from the generic one and adding details specific to the video you are encoding. This may seem like a pointless step, and MeGUI certainly doesn't require it, but there are good reasons for doing it.

The first is that it's convenient if you need to go back to see what settings you used later on. There are other ways to find this information, but none are as convenient as just opening a profile. Plus, if they are in a separate profile you can easily go back and make minor changes no matter what other encoding jobs you have created afterward. It's trivial to delete a profile you've created at any point in the future so there's really no down side to it.

Step 1 - Copy A Generic Profile

Copying a x264 profile to create a new one in MeGUI -

Start by loading the generic profile that matches the video you are encoding and using the New button to copy it.

Step 2 - Set The Bitrate

Enter the bitrate to encode your H.264 file in MeGUI -

Now enter the bitrate provided in Lesson 3 by the Bitrate Calculator.

Now that you have your generic Blu-ray profile created, in the future you can select it in the main MeGUI window before opeing the Bitrate Calculator. The bitrate will automatically be loaded when you open the x264 Settings dialog so all you have to do is use the New button to copy the generic settings along with the bitrate into your new profile.

Step 3 - Load QP File

If you created a chapter (QP) file for your video you will need to load it from the Misc tab. If you are creating a template, rather than settings for a specific video source file, you shouldn't set this option as it will almost certainly change for each new encoding job.

x264 QP file selection in MeGUI -

1. Enable Chapter Creation Using A QP File

Checking this box activates the use of a QP file to set chapter points.

2. Browse For QP File

Use this button to browse for and open a QP file telling x264 to prepare the list of frames to be chapter points. See Lesson 3 for more information on the requirements for chapter points and creation of a QP file.

Step 4 - Update Your Profile

Updating an encoder profile in MeGUI -

Any time you change any settings in a profile you will need to update it before exiting the settings dialog.

Save video encoder settings when exiting the settings dialog in MeGUI -

If you happen to forget, and sooner or later you probably will, MeGUI will ask you if you want to save the changes to your profile when you exit the settings dialog. Make sure to answer yes or else your changes will be saved to the scratchpad profile instead. While you can still use them for encoding, assuming you don't overwrite the scratchpad before queueing your encode, but it could get confusing if you go back to look up your settings later.

Step 5 - Exit The Video Encoder Settings Dialog

Exit MeGUI's video encoder settings dialog -

After saving the x264 profile for your video file, use the OK button to exit the video settings dialog. You are now ready to create the encoding job.

Create & Queue Your Encoding Job

Once you are back to the main MeGUI window you should be ready to create your video encoding job and add it to the queue to be processed. But before you hit the Queue button make sure to doublecheck some settings.

Create a video encoding job in MeGUI and add it to the Queue -

1. AviSynth Script

Verify that the correct AviSynth script is loaded. If not, click the button to load the correct AVS file.

2. Output File

By default MeGUI will create your new H.264 file in the same folder as the source. You can change the ouput folder and filename using this button.

3. x264 Profile

Verify that the correct x264 encoder profile is loaded as well. If it says Scratchpad you may have inadvertantly saved your settings to that profile instead of the one you created for this job. If so, you can go back into the profile editor and double check your settings. Make sure to update if you change anything. Then come back and verify the profile being used in this window.

4. File Format

If you are going to be using a professional or prosumer authoring tool to create your Blu-ray disc you must set the file format to RAWAVC. If you forget to do this and MeGUI puts your encoded video into a MKV or MP4 container you will have to start the encoding job from the beginning2.

5. Queue Encoding Job

Once you are satisfied with all your settings, use the Queue button to create a video encoding job and add it to the queue.

2 In order to be Blu-ray compliant a video file must contain certain timing information which an authoring program can use to test it against a reference Blu-ray player design. This ensures every Blu-ray player, assuming it has properly implemented the requirements for certification, will be able to play it. Without that information the authoring program will have no way to verify it is Blu-ray compliant and will reject it automatically. When H.264 video is put into most containers, including both MKV and MP4 files, the timing information is discarded and it cannot be retrieved. This does not apply to purely hobbyist tools, but you can be sure any software officially certified for Blu-ray (BDMV) authoring will reject such a file, forcing you to encode it again.

Continue To Lesson 5

Once your video is encoded it's time to turn your attention to the audio that goes along with it. If you cut anything out of your video you will need to edit the audio to match. And of course you need to make sure it is in a Blu-ray compliant format. Most commonly this means encoding it as Dolby Digital. The next lesson will cover both issues.

AfterDawn Blu-ray Encoding Tutorial

Written by: Rich Fiscus
Last updated: