AfterDawn.com
AfterDawn Blu-ray Encoding Tutorial

Blu-ray logo - AfterDawn.com

AfterDawn Blu-ray Encoding Tutorial Lesson 5
Encode AC-3 Audio


Up until now, the lessons in this tutorial have focused on video, from decoding to editing to encoding. That's natural considering how complex a subject it is. But, unless you are making silent movies, eventually you have to also consider the audio that goes with, and comes from, your video files. In Lesson 5 we will focus on preparing the audio streams you will use as assets for your Blu-ray disc.



The Complete AfterDawn Blu-ray Encoding Tutorial


Creating assets for Blu-ray authoring is relatively 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 5 Objectives


  • Identify the format of your source audio
  • Encode your audio to AC-3 if it is not already in that format
  • Use the Cut file generated in Lesson 3 to edit your audio to match your video (if applicable)


There are essentially two questions you need to deal with when it comes to the audio for your Blu-ray disc. First, is it encoded to a Blu-ray compliant format. There are numerous formats which are allowed on a Blu-ray disc, but when it comes to sources which don't originate from a professionally authored disc you can generally narrow it down to just two - Dolby Digital (AC-3 or A52) and LPCM (uncompressed).


In this lesson I will not be covering LPCM. That will be the subject for a future, more advanced, installment. Instead I am assuming that you will be using Dolby Digital for your Blu-ray since it is such a common format and MeGUI includes tools for encoding it.



Cutting Audio To Match Video Edits


Besides the format, another possible concern you may need to address is matching up the length of your audio source with your video. This should only be an issue if you used the AVS Cutter to edit your video prior to encoding. That's where the Cuts file produced at the end of that process comes into play. When you encode your audio you will need to make sure to load that file and matching edits will be made to the audio stream prior to encoding. If your audio does not need to be encoded there is also a separate Audio Cutter tool which will perform the edits without altering the rest of the audio.




Possible Audio Sources


Before you can figure out what, if anything, you will need to do to process your audio, you need to figure out what type of audio source you have. There are basically three possibilities.



1. An Extracted Audio File

If you opened your source using either the DGIndex file indexer or HD Streams Extractor you should have ended up with one or more audio files which were extracted from your source. Typically these will be Dolby Digital or LPCM files. If they are LPCM audio, they will typically be either WAV or FLAC (losslessly compressed) files.

2. Separate Audio Source

Your audio may have already been in a separate file when you began. In that case you can treat it just like an audio file extracted via MeGUI

3. An AviSynth Script

If you indexed your source video using FFIndex but didn't use the HD Streams Extractor first, you would have ended up with a second AviSynth script (AVS file) which you can use to read the audio from your source. Although this is not optimal if your audio is already in Dolby Digital format since it will require you to re-encode, chances are the audio was in some other format, most likely AAC (Advanced Audio Coding) which would have to be converted to AC-3 anyway. In that case having an AVS file as your source can be quite advantageous since it makes matching any edits you may have done very simple.


Whatever type of audio you have, whichever tool you used to extract it should have provided you with all the details you need to determine what, if any, processing is necessary. Below you can see examples taken from FFIndex (top left), DGIndex (top right), and the HD Streams Extractor (bottom). Notice that each one lists the encoding, number of channels, and sampling frequency. Additionally, if your audio was extracted by DGIndex the filename will include the bitrate it is encoded at.



Audio stream details in MeGUI's extraction tools - AfterDawn.com



Dolby Digital Sources


If your audio is already in Dolby Digital format and has a samplerate of 48kHz, 96kHz, or 192kHz, you can skip encoding entirely. If you did not use the AVS Cutter to trim your file you can simply stop at this point and go straight to authoring your Blu-ray disc. If you did use the AVS Cutter on your video, continue to the next step where you will edit the audio to match.



Cutting Dolby Digital Files


If you did use the AVS Cutter to edit your video, you will need to cut the audio to match. This is easily accomplished using MeGUI's Audio Cutter.



Open MeGUI's Audio Cutter tool - AfterDawn.com

Open the Audio Cutter from MeGUI's Tools menu.




MeGUI's Audio Cutter interface - AfterDawn.com

1. Source Audio File

First open your source AC3 (Dolby Digital) file.

2. Select Cuts File

Next you will need to open the Cuts file you created with the AVS Cutter back in Lesson 2.

3. Output File

Finally you will set an output file which will be identical to the source, except with the sections indicated by the Cuts file removed. In other words, no encoding will be done so no quality will be lost.

4. Create Job

Click this button to create the audio cutting job and add it to MeGUI's queue.


Once your audio cutting job completes you are ready to move on either to any additional audio streams or to authoring your Blu-ray disc.




Encoding To Dolby Digital


MeGUI has two different tools capable of encodng AC-3 (Dolby Digital) audio. One of them, Aften, has been out of development for quite some time so I recommend that you use the other tool - FFmpeg - instead. In either case, though, the encoder settings interface is identical so you can use these directions for either one.



The Audio Encoding Interface


You will find the audio encoding interface at the bottom of the main MeGUI window.



MeGUI's Audio encoding tab - AfterDawn.com

1. Audio File or AviSynth Script

Start by opening the audio file which MeGUI extracted from your source. If you indexed with FFIndex you will have an AviSynth script (AVS file) with a name referencing a track number. This is the file you will use as your audio source.

2. Select Cuts File

If you edited your video with the AVS Cutter, you will need to load the Cuts file created at the end of the process so the audio can be edited to match before encoding.

3. Output File

This should be self explanatory. It's the file MeGUI will be creating for you.

4. Encoder Profile

By now you should be familiar with MeGUI's profile-based interface. Select the FFmpeg *scratchpad* option here. Alternatively, you can select one of the Aften profiles or a custom (FFmpeg or Aften) profile you have already created for yourself.

5. Configure Audio Encoder Settings

This will open the audio encoder settings dialog. See below for detailed instructions on configuring either of the AC-3 encoders.

6. Create 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.


AC-3 Encoder Settings


MeGUI AC-3 encoder options - AfterDawn.com

1. New Profile

This works essentially the same as MeGUI's other profile interfaces. Use the New button to copy the current settings into a custom profile to reuse them later.

2. Preferred Decoder

Regardless of the source, AviSynth is used to open and process (but not encode) your audio. This setting determines what filter is used to open it. Unless you run into problems you shouldn't change it. Otherwise you can choose FFAudioSource, which uses FFmpeg libraries, or DirectShow, which attempts to use Windows' DirectShow interface.

3. Ouput Channels

You can choose to keep the original channel configuration, downmix streams with more than two channels to stereo, or upsample stereo sources to surround. You can even convert your audio to mono. Given the extremely small size of even the largest AC-3 file compared to the space available on a Blu-ray disc, there really isn't any advantage to downmixing. Likewise, there really isn't anything to be gained from upmixing since AviSynth has no way to know what sounds should be directed to which speakers. As a general rule you should simply keep the original channels.

4. Sample Rate

This should be set to either Keep Original or Change to 48000Hz. The other sample rates listed are not Blu-ray compliant.

5. Dynamic Range Compression & Normalization

These options control the AC-3 settings used to prevent the difference between very quiet and very loud sounds from becoming too great. If you don't know what they do, don't mess with them.

6. Bitrate

Typically the bitrate used for encoding stereo AC-3 files is eithe 192kbps or 224kbps. Surround streams for DVD are usually encoded at 384kbps or 448kbps. Blu-ray allows up to 640kbps. Whether it is worth going that high is something only your own ears can tell you. Once again, though, it is next to nothing compared to the size of a Blu-ray disc so it probably won't hurt.



Continue To Lesson 6


So far you have learned about techniques tailored for encoding a single title (video file) for Blu-ray, but what if you want to put multiple titles on a disc? In the next lesson you will be introduced to a technique for calculating bitrates for encoding multiple videos and some suggestions for tweaking the process to maintain even quality among sources with varying encoding requirements and complexity.




AfterDawn Blu-ray Encoding Tutorial


Written by: Rich "vurbal" Fiscus
Last updated: 13 August 2012