AfterDawn.com
AfterDawn Blu-ray Encoding Tutorial

Blu-ray

AfterDawn Blu-ray Encoding Tutorial Lesson 6
Advanced Bitrate Calculation


This is the sixth lesson in the AfterDawn Blu-ray Encoding Tutorial. In Lesson 3 you learned how to calculate the bitrate for a single video file to be authored to a Blu-ray disc, in Lesson Four you learned how to encode the video using that bitrate. Now you will learn to combine those skills to calculate the bitrate for multiple video files so they will fit together on a single 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 6 Objectives


  • Learn how to calculate a single bitrate for multiple files
  • Learn how to set varying bitrates for different files for consistent quality
  • Learn how to set bitrates for multiple files to guarantee specific titles are encoded with higher quality than others
  • Understand the relationship between bitrate, resolution, framerate, and quality


Strategies For Encoding Multiple Video Files


While bitrate calculations are relatively straight forward for a single file, things can get much more complex when you have multiple titles to encode. For starters there's the fact the Bitrate Calculator can only handle one file at a time. Then there's the additional complication that encoding two different files at the same bitrate will tend to result in different quality for each. Sometimes the difference is insignificant, perhaps even indistinguishable to the human eye. Other times it is obvious to the point of detracting from the viewing experience. Although the various solutions to these problems are more complex than it would be appropriate to cover here, I can at least provide point out, in general terms, some possible solutions.



Using Combined Clip Length


The simplest approach to calculating the bitrate for multiple files is simply adding the length of all your video clips together and entering it manually in the Bitrate Calculator.



Step 1 - Gather information from each video


To figure out the combined playing time you can use the Bitrate Calculator. Simply open each file, as in the instructions above, and look at the length information.



MeGUI Bitrate Calculator source information - AfterDawn.com

1. Frame Count

The easiest way to accurately add the lengths of different clips together is by using the number of frames. This will only work properly if every clip has the same framerate. Otherwise you should use the number of seconds instead.

2. Show Total Seconds

The clock in the top, left corner toggles the display for clip length. Click it to see the total number of seconds.


MeGUI Bitrate Calculator showing the number of seconds - AfterDawn.com


Although technically not as accurate as using the number of frames to calculate length, the error from dropping fractional seconds shouldn't be significant enough to cause any problems.



Step 2 - Manually enter combined video lengths into Bitrate Calculator


Once you are finished determining the length of each video clip, add them together. Now you can enter either the total number of frames or total number of seconds into the Bitrate Calculator.



Entering clip length manually in the MeGUI Bitrate Calculator - AfterDawn.com

1. Replace Clip Length

Both the number of seconds and number of frames can be manually entered. Use the total you calculated from all your clips.

2. Video Stream Size

This field shows you the bitrate to use for your videos. Make sure you have filled out the rest of the fields as per the basic instructions in Lesson 3.



Adjusting Bitrates For Cosistent Quality


The problem with the method I have just detailed is that it's pretty much guaranteed to produce different quality output for each video file. Every clip is unique, and so is the bitrate required for any given quality level.


That's not always a problem. Sometimes the difference is so small as to be invisible to the human eye, particularly if you aren't looking for it. However that's not always the case. In particular, home videos shot with consumer grade equipment, whether that be a HD camcorder, a regular digital camera, or even DSLR, will tend to vary in bitrate requirements from one clip to another. Ideally there would be a way for you to compensate for differences between files. In fact, you can do just that, albeit with some additional work and potentially much more time than simply setting a single bitrate for all files.



Step 1 - Gather information from each video


This is exactly the same process as the first step above. You need to know the length of each file and add them together. This time, however, the purpose is simply to give the Bitrate Calculator enough information to accurately determine the size of the audio streams.



Step 2 - Manually enter combined video lengths into Bitrate Calculator



Total video size in MeGUI Bitrate Calculator - AfterDawn.com


Once again this works the same was as described above, but with one major difference. Instead of the bitrate, you are looking for the total video stream size. You won't be using this immediately. Instead you will be saving it for a later calculation.



Step 3 - Encode Videos In Constant Quality (CRF) Mode


Next you will need to encode your video in Constant Ratefactor mode. In this context Ratefactor is a representation of quality. This will work almost exactly like the encoding you did in Lesson 4, all the way up to specifying a QP File for chpater points if appropriate. However, you will need to switch the encoding mode to use a quality-based strategy and select a CRF (Quality) number.



MeGUI x264 settings for quality based encoding - AfterDawn.com

1. Encoding Mode

Set this to Targeting quality.

2. CRF Number

Set a number between 16 and 40 for the quality (Q number) setting. This must be the same for all files.

What number you set this to is less important than making sure you set it to the same number for every file. Typically anywhere from 18 to 24 (lower is better) is used for excellent to good quality. However, since you aren't actually encoding for viewing, but rather to see what files require more bits, you may want to set it as high as 30 to speed up encoding time somewhat1.


This extra encoding step is the real key to fine tuning bitrates for different files. When you are done, you will be able to use x264's decisions to see if certain clips need a significantly average bitrate to retain consistent quality across your disc. Although it may not be a perfect comparison, you can bet if a one video requires twice as high a bitrate as another at one Q setting, it will probably need about the same if the quality is lower or higher.



1 Although I mention the possibility of using a CRF (Quality) value as high as 30, if you have a fast enough computer or enough time that using a value which produces quality similar to your final encode doesn't concern you, the results will probably be more meaningful. Beyond a certain point (which varies by the source) you can expect the quality loss from a high CRF to make comparisons meaningless. I personally try to stick with a quality setting which matches what I would use if disc size were not a limiting factor.



Step 4 - Determine File Sizes


Next you will need to figure out how big your encoded video files are. You will need the total size of all files as well as the individual size of each file. The simplest way to do this is using the Details view in Windows Explorer. The image below shows how to set this view in Windows 7. It will be slightly different for other versions of Windows.



Viewing the size of your encoded videos in Windows Explorer - AfterDawn.com

1. Details View

You will need to set Windows Explorer's View setting to Details. This will provide you with a column-based view of your files, including a listing of the size.

2. Record File Size

This column shows the size of each file. You may want to write these down or create a text file listing them.


Once you have the file sizes, add them all together to find the total size. Then divide the size of each file into that total. For example, in the screenshot above the total of all files is 13,303,334. The units (kB) don't matter at this point. Dividing the size of the first file by the total I come up with 0.10038881982516563141239632110266. I'll round that number to 0.10. That means this file should receive 10% of the total space available on the disc for video. Doing the same with the other files I get 10%, 20%, 36%, and 25%.



Step 5 - Calculate Bitrates


Now you are ready to calculate the bitrate to use for encoding your files. Multiply each of the numbers you got in Step 4 by the total video size you calculated in Step 2. You will use that number for the Custom size in the Bitrate Calculator.


For example, I came up with a total video size of 21.92GB. Multiplying that by .10 (10%) for each of the first two videos I get 2.192GB. That will become the Total File Size for the Bitrate Calculator just for those two files.

Calculating different bitrates for files on the same Blu-ray disc in MeGUI - AfterDawn.com

1. Total File Size

The total file size for this step will be the percentage you just calculated for this particular file. In my case, I have entered 2.192GB for my first file.

2. Remove Audio Streams

You have already figured in the space for audio streams back in Step 2 so you need to make sure not to do it again here. You can either click the button to remove the audio track which is added by default or simply reduce the bitrate to 0.

3. Calculated Bitrate

The bitrate listed here is what you will encode this file at. At this point you can continue encoding normally in Bitrate-based (ABR) mode as in Lesson 4.


Repeat this process for each of your source (AVS) files, recalculating the new Total File Size for each based on the total from Step 2 and the percentages from Step 4. In my case I ended up with bitrates of 22,921, 23,495, 23,244, and 23,218 as the bitrates for my other files.




Is It Worth The Extra Time & Effort?


Ultimately it's up to you to decide whether the extra work, not to mention quite a bit of extra encoding time, is worth it for the results. If you consistently find yourself ending up with bitrates which are extremely similar for every file, chances are good you wouldn't have noticed the difference using a single bitrate for all of them.


However, if you look at my example you'll see that the first video ended up with a significantly higher bitrate using this more advanced method than it would have otherwise. Initially all files were set to have a bitrate of 23,650kbps. And, in fact, most of them ended up with something close to that using the second method as well. However, one file ended up with a significantly higher bitrate of 30,658kbps. To me that makes the process worth it. While the other files will probably be indistinguishable using either bitrate. That particular one will almost certainly be visibly improved.




Prioritizing The Quality Of Individual Titles


The other advantage to using the quality-based bitrate calculation method is the ability to tweak the quality of individual titles to ensure more important videos are the best quality possible. This is something you see all the time on major studio Blu-ray releases, and DVDs for that matter, where the main feature often ends up looking much better than the extras.


While you may not be preparing big budget movies for mass production, you may still find that strategy useful. Just like a standard commercial release, your own home videos could easily have a single main feature accompanied by some extras. For example, if you are making a Blu-ray disc from a collection of wedding videos, you may find it necessary to encode a clip of the wedding party relaxing at lower quality than the footage of the wedding ceremony.


To accomplish this, simply use the quality-based method described above, but instead of using the same Quality number for each, adjust the Q number to increase or decrease the quality of one or more titles. Remember that lower numbers indicate higher quality and you can adjust them by less than 1 (ie 30.2 or 35.7), however in most cases you probably won't have any need to do so.



Making Compromises


You may find that it's simply not possible to encode all the video for a given Blu-ray project at the quality you want without making adjustments beyond bitrate, and even beyond encoder settings in general. You may need to resize some titles to a lower resolution, maybe even to standard definition (720x480 or 720x576) to avoid intolerable encoding artifacts. In less severe cases you may find that simply deinterlacing 1080i to 1080p is enough or you may need to remove every other frame in a 720p60 or 720p50 stream.


Ultimately all lossy encoding, especially when it is tied to a format with strictly media size and bitrate restrictions like Blu-ray, is a series of tradeoffs. Sometimes you simply can't get the results you want without lowering your expectations. However, the more discs you encode and author, the more realistic your expectations will be at the beginning of the process, and the happier you will be with the results you are able to achieve.




Continue To Lesson 7


Most people think of the difference between Blu-ray and DVD purely in terms of video, but it also offers significant advantages in terms of audio. In the next lesson you will be introduced to high resolution audio, and learn how to use a free audio editor called Audacity to create audio assets which take advantage of Blu-ray's improved audio capabilities.




AfterDawn Blu-ray Encoding Tutorial


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