Digital Digest
  • About the Author
  • Email
  • Disclaimer
  • Essential Links
  • Essential Tools
  • Ethics, Piracy & Philosophy
    Convert DVDs with Flask Mpeg
  • Extracting the DVD
  • Using FlasK Mpeg
  • Resizing in Flask
  • Convert DVDs with Mpeg2avi
  • Extracting the DVD
  • Using Mpeg2avi
  • Resizing in Mpeg2avi
  • Advanced DVD Conversion
    Convert DVDs with DVD2AVI
    Nandub SBC Encoding
  • Using Nandub
  • Using DivX 4.0
  • Audio / Video Editing
    Advanced VirtualDub
    Digital Video Capture
  • Video Capture: Part 1
  • Special FX Tutorials
  • Morphing Buffy Style
  • Star Wars LightSaber Effects
  • The Exorcist Effect
  • Other Video Formats
    VCD & SVCD Guides
  • DVD to VCD
  • AVI to VCD
  • Multimedia Guides
  • DivX with Subtitles
  • Mutilanguage DivX
  • Multimedia DivX Pt 1
  • Multimedia DivX Pt 2
  • Appendix / Tips
  • Aspect Ratio's
  • Resizing DVD's
  • DivX Quality Guide
  • Bicubic vs Bilinear Resizing
  • Deinterlace Method Test
  • Video Comparisons
  • WM8 Quality
  • Basic DVD Structure
  • NTSC / PAL & Interlace
  • AVI 4GB Limit
  • Key Frames & Delta
  • Monitor Setup Guide
  • FAQ's
  • Questions Answered
  • Downloadable PDF Guides
  • Glossary
  • Word Definitions
  • My Guides Translated
  • Go Here
  • Nandub / SBC Encoding

    Everybody's talking about it, the new Smart Bitrate Control (SBC) method of encoding DivX movies. The program used to do this is called Nandub and was written by a fellow who goes by the handle_nn_! Nandub is basically a 'hacked' version of VirtualDub (but hacked with permission). It controls DivX encoding frame by frame! Doom9 was the first to show everyone how to use Nandub. If you haven't seen Doom's webiste yet I think you should check it out because, well, he's such a cool bloke! You can go to it by clicking Here!

    To the untrained eye it looks like Nandub produces higher quality at a smaller filesize! For example, you all know that a movie encoded with the Fast Motion codec at 6000kbps will always produce a final movie worse looking than a Low Motion encoded at 3000kbps! So you think lovely I'll use Low Motion and it will be half the size and twice the quality, right? Wrong! If you compare the 6000kbps movie to the 3000kbps movie you will find that the filesize of the 3000kbps is actually twice that of the 6000kbps movie! The same is true for Nandub or Windows Media Encoder 8 or even MM4 encoding (such as MakeFilm or AVIRevolution). When you compare one of these clips to the same clip encoded by any normal DivX codec the Nandub or MM4 clip will always be larger or the same quality. The power of these programs is only their ability to make the most efficient use of all the space available. To do this Nandub uses the best possible method a 2-pass Variable Bitrate (VBR) encoding scheme!

    Nandub certainly has the potential to produce the best results above any other method so far. But unfortunately for all its millions of controls most of them do very little to produce better quality. I have found that only two or three options are responsible for a significant quality control. I will highlight these specifically so you don't spend years trying hundreds of different settings that do practically nothing! I think the real reason Nandub has so many controls is because it is still in its experimental stage. The creator of Nandub could no doubt easily make it with only two or three settings. But instead he gives us full control over every possible setting and lets us decide what we think works best. I think this is a great idea and, for this reason alone, its worth the effort. We are basically beta tester for Nandub. To prove this certain options (such as half the DRF controls) have already been ruled out and will probably be removed in future versions!

    In this guide I will explain all the controls as I understand them and I will show you my way of encoding with Nandub. My method is probably a little different from what most people are doing, but that doesn't mean I'm doing it a better way! As usual the more complex the program the less documentation is given so Nandub comes with a whole single page of no information at all! This means most of us will not have a clue what any of the controls really do! I'm not even completely sure how they work myself. With that word of warning, and if you still feel strong enough after all that blurb, lets continue.


    Before I start you will need:
    Nandub 0.21
    VirtualDub 1.4d

    I'm assuming you are either frameserving from FlasKMpeg to Nandub following my AVISynth method found Here or that you are using an AVI file created from the DVD2AVI guide found Here. Of the two methods I'd say the DVD2AVI method is the easiest and most reliable so go with that if you are not sure.



    If you haven't already installed VirtualDub 1.4d I suggest you do so; just put it on a folder on your main drive (usually C:). Then unzip Nandub and copy all of the contents from the Nandub folder into the VirtualDub Folder like this:

    Thats it! Now to run Nandub you open the VirtualDub folder and double click on the 'Nandub.exe' file.



    Since we used DVD2AVI to create an AVI file we can just open it like we would in VirtualDub. If you are Frameserving from Flask just open the AVS as normal too.

    As I said, Nandub is a hacked versio of VirtualDub so it also has most of VirtualDub's features. This means that if you want to crop or resize your movie you can do so in exactly the same way you would do it in VirtualDub. If you're not sure how to use VirtualDub for this check out my filter guide Here.



    Normally with MM4 movies such as MakeFilm or AVIRevolution, FairUse etc., you will need to encode the same movie a few times so that each one can be joined together. Nandub only ever does two passes and still gets better results. The first time it encodes you do not need to set any options in Nandub itself, but you do need to make sure you have cropped and resized your movie before this first pass, otherwise you will screw up the process.

    Once you used all the crop and resizing filters you need you will need to make sure it is going to generate a stats file. Your stats file will contain all the informaton Nandub find on the 1st pass. So choose:

    Video > SBC Options > Generate stats
    Video > SBC Options > No AVI output

    As you can see a tick mark appears by each option when it is enabled. The 'No AVI output' option is so Nandub doesn't fill up your hard disk with a movie on this first pass. All we need it to do is create a stats file on the first pass so we want No AVI output checked too.

    Once that's done we simply go to: File > First Pass

    It will ask you what you want to call your stats file, so give it any name you like. It will then start encoding. This will take about as long as encoding the whole movie, so do it overnight or when you are not using your computer for anything else!

    Once the first pass is done you will end up with a small binary file called something.stats. The 1st pass only needs to be done once per movie. If your movie doesn't turn out very nice after the second pass, you can still use this stats file again. This saves you needing to do the 1st pass again and again because it doesn't matter how you configure the options in Nandub, the stats file always records the same information from each movie. but obviously you need to make a new stats file if you are encoding a different movie. You will also need a new stats file if you change the cropping or resizing setting etc., so be careful.



    Now that the first pass is over and Nandub has analysed your movie its time to really encode it. To do this you have to tell Nandub how you would like it to compress your movie - this is the complex bit!

    First lets set up VirtualDub for keyframe detection. Go to: Options > Preferences

    Click on the Scene tab, move the Interframe cut to 215 then press save.

    Back to the main controls again. Make sure the 'Generate stats' and 'No AVI output' options are no longer ticked. And we will go to out first Nandub setting.


    DivX. (ctrl+X)

    Go to: Video > SBC Options > DivX...

    Up pops this dialouge box:

    Bitrate Kbps

    As with all DivX encoding methods the bitrate needs to be set. Use a bitrate calculator to work out the best setting to use. I tend to guess the bitrate these days and would probably put in 1000. You must keep in mind that this is just a rough guide and it is still possible to go over or under your set filesize so don't try and be smart and put a huge amount. I'd say always use the number you calculated from your bitrate calculator! Never change it even if your movie is far to large or far too small! The final filesize can be ascertained by altering how the movie is encoded in other options.

    Minimum Allowed Bitrate

    This gives Nandub an idea on the minimum quality you want to keep the movie. I suggest you set it to about 600kbps! Don't bitch about the best setting for this one because it doesn't seem to make much difference, just don't go lower than 300kbps and you should be fine.

    Keyframe Interval

    The keyframes in Nandub are inserted based on the detection of scene changes (just like the M4C and VKI codecs that were about a while ago). If you are not sure what a keyframe is check my guide Here. In a movie a scene change is described as when the camera switches from one person to the next. This produces a huge change in the picture. Since Mpeg compression is based on only saving the differences between two frames, if the next frame in the sequence is a completely different one from the last (as is the case for almost every scene change) then it is better to start each scene with a whole keyframe rather than one built out of blocks. And, since all the frames after the first one of a new scene are based on the first, they will all appear slightly better quality as a result of the correctly placed keyframe. In movies the average time between each keyframe is between 2 and 8 seconds.

    Nandub's Keyframe interval option is designed to override the automatic keyframe detection and place keyframes every so many frames. We don't want this to happen so we set a keyframe only every 9999 seconds!

    Internal SCD

    Internal Scene Change Detection (SCD) is designed to work in conjunction with the keyframe detection set in the VirtualDub preferences. Experimenting with these scene detection options are pretty futile, nothing you do will make significant improvements in quality, so there is no need to start pulling out your hair asking people for the best settings. The settings I have suggested should keep Nandub form producing too many keyframes. A setting of 100% for most movies works great on this option, but if you find it is having problems putting in keyframes on certain movies (dark movies usually) you can lower it by 10 or 20%.

    Space KFs

    Space Key Frames (KFs) is in my opinion a very important feature of the keyframe options. It is possible that the keyframe detection could become too sensitive at certain parts of the movie and start inserting loads of keyframes in a row. This could cause jerky playback or just increase the filesize too much. To prevent this the Space KF option sets a minimum space of frames between keyframes. Since the shortest scene in a movie usually lasts at least 2 seconds we should put 50 frames (which is about two second of time). You can choose more frames if you think too many keyframes are being put in your movie or if you really need to save space but its probably not needed.

    Anti-Shit Threshold

    Quaint name, eh? Remember when you sometimes got a dead frame when you were encoding with the old DivX codec and the movie froze but the audio kept going?! Well this option should help to make sure that this will never happens again. It is based on the idea that a corrupt frame has gone off the scale. A setting of 1 reencodes all frames as a keyframe so we must set it really high to prevent this happening. I always use 120% on this option and it appears to work okay. I doubt there is any reason to play around with other settings unless you notice dead frames or too many keyframes because of it. This option is turned off by default because it will slow down encoding. If you've never had problems from frozen frames then always keep it off it does absolutley nothing except prevent bad frames.



    Go to: Video > SBC Options > Motion Detection

    On high motion scenes the DivX codec will increase the bitrate used and on low motion scenes it will lower the bitrate. This motion detection is based on noting the differences between frames. If there are big differences between a sequence of frames this means there is lots of action. And to store these big differences we need big amounts of memory. This is why the codec gives more bitrate on high action scenes and less on low motion scenes. So this section lets you configure how it detects motion.

    Note that the settings above do not seem to work best in all cases. I've been emailed saying that much better results are gained by putting the detection up to the full 300. This is especially the case on very high action movies and some Japanimation movies. Since the difference in final filesize is only about 300kb more for a 20 min movie it could well be worth it.


    The span is how many frames it compares to determine motion. The default setting is 8 and that means it will check 8 frames before the frame its on to 8 frames after the frame its on. So choosing a setting of 8 detects 16 frames in all (eight to the left and eight to the right). The smallest amount of frames you can check would be 1 (one to the left and one to the right). The highest amount you can check would be 24 frames which is a whole second to the left and a whole second to the right. Obviously the more frames you compare the longer it will take to compress. I see no real reason to choose any other setting than the default 8. You can play around with it but I doubt you will be able to notice any quality change from another value.


    This determines how big a difference between frames it should check for. The highest most sensitive setting is 1 and the lowest least sensitive setting is 50 but I doubt it even uses that. The best setting is probably about 10 but some use as low as 2. The idea is that if you think the codec is not upping the bitrate correctly you can make it more or less sensitive to changes. I'm paranoid so I put 3 like Doom but I doubt it does much better because of it.

    In truth none of these motion detection settings really seem to make much of a difference. You will not get a significantly smaller or larger movie by changing them. You will not get a significantly better quality picture by changing them. There really is no need to keep asking people what settings are best for these.

    Fast Motion & Low Motion

    The amount of motion determined in each frame is rated on a scale from 0 (no action) to 300 (highest action). I have it on good authority that no matter what movie you have the scale will never reach the 300% mark. The reason it has a Low Motion and a High Motion slider bar is to set it so that Fast motion codec can take over and encode the action parts of the movie while the low motion codec takes over and encodes the quiet scenes. Since Nandub completely controls the bitrate there is probably no benefit in doing this anymore. The fashion with Nandub users is to use only the Low Motion codec by turning the slider for the Fast Motion up to 300% so that Nandub can never use it! I actually prefer the opposite! I turn the Low Motion up to 300% and only use the Fast Motion codec on the default of 200. Why? Because I have compared the way Nandub uses the Low Motion codec and the Fast. My conclusion is that on low motion scenes they look just as good as each other. But on action scenes the Fast Motion still has a slight edge in terms of quality and compression. This is to be expected since the Fast Motion codec was made after the Low Motion codec as an improvement. Admittedly it didn't seem like an improvement since they also changed the way it used the bitrate. But Nandub solves this problem so I see no reason not to use Fast Motion now.

    Crispiness Modulation

    This is similar to the Smoothness / Crispiness setting found on the original DivX codec. On low action scenes it's better to keep the movie sharper so it's clearer. But in high action scenes it's better to make the image slightly blurrier. This blurring helps to hide macroblocks because it takes less memory to compress a blurry image than it does to compress a sharp one. The blur is very subtle and since high action scenes are so fast the human eye will not notice any loss of detail.

    To enable this option you must make sure the Enable BR Modulation box is ticked. It doesn't really make a big difference what you set it; the changes are barely noticeable! It basically works like a backwards version of the DivX Smoothness setting. A 30% value is equivalent to 70% on the original DivX codec. Most people use 25-30 but perhaps more is needed for single CD rips or movies with lots of action.



    Go to: Video > SBC Options > Compression Levels

    Yes, I know we skipped Bitrate Reservoir but we will get back to that in a second. This section looks complex but actually it's the easiest to set of the lot and it will make one of the biggest differences in final quality.

    The DivX codec compresses each frame of a movie based on a compression ratio of between 0 and 32 percent. The x0 means don't use any compression and the x32 means use the most compression possible. In the original Nandub the idea was to let you set the level of compression exactly for every kind of motion, and that is why there are six lines to fill in! But soon it became obvious that this was a waste of time! Instead the only settings you need to worry about are those on the first line: the DRF min and max setting. It is very important that you disable all the "when motion is over" boxes by changing them all to 300; this will literally turn them off! Hopefully newer releases of Nandub will not have these extra confusing lines in it.

    So what settings should you put in the top Min and Max DRF then? It appears that the Low Motion codec always used a minimum compression of x2 and a maximum of x11. Whereas the Fast Motion codec always used a minimum compression value of x7 and a maximum value of x16. In truth I believe this to be an oversimplification of the matter. To illustrate, a statement like that is like saying that the Fast Motion codec on its best quality setting was not even as good quality as the Low Motion codec on its worst setting!

    So let's talk about practicality instead. Just using 2 as a Min and 2 as Max settings gives us best possible quality but also takes far too much space! It is also very, very restrictive and makes the 2-pass variable bitrate almost a waste of time. You could quite happily forego the first pass and save yourself a great deal of time. For Nandub to work efficiently you must give it a good range of compression. In the case of the original DivX codec we are assuming ten levels of compression were available (x2 to x11). For example, what happens when Nandub finds a totally black screen and all you give it is the ability to compress at x2? What a waste of space that would be when it could use double or triple that compression with no quality loss!

    In my opinion you should always set the min bitrate to 2 because you are robbing yourself of the extra quality if you don't. Higher settings did not go well for me even on single CD rips. If you are more concerned about making a really, really small file perhaps using a minimum of 3 or 4 is okay but don't blame me if it looks crud. After extensive experimentation all I can say is that a Min of 2 and a Max of 8 give best results in most cases! I've tried 2-2, 2-3, 2-4 etc., all the way up to 2-16. It appears that the best compression to size ratio for the average movie is 2-8. Even using 2-4 will not produce a significant increase in quality and using 2-16 will not produce significantly more compression. To cut a long story short, I now always use Min of 2 and a Max of 8! Ironically this is what Doom has said all along which shows he's been doing his homework :)



    Go to: Video > SBC Options > Bitrate and Reservoir

    Okay this section is the one that will effect the final quality of your video the most. It is also the section that is most confusing to people so I'll take it slow.


    Just leave this blank. I think it must be an option inserted so that the creator of Nandub could test his 1st pass stats creation?? I'm told it is used automatically anyway to create the stats file anyway, so just ignore it.


    Stats File

    On your second pass you will be using the information contained in the stats file. If you are using someone elses stat file you can select it by pressing th browse button. Provided you did the first pass already, this file will already be selected.



    Strangely enough this has nothing to do with the amount of compression that will be used on your video! To illustrate it's use we have to understand what Nandub actually does with the stats file. On the first pass your movie is encoded at the best possible quality a DivX can do (i.e. 6000kbps). As it is compressed instead of saving the video it examines each frames and detects what bitrate was used. Since the DivX codec is not looking to fit the movie in a set space it can go as high or low as is needed for perfect quality. The stats file in effect is a bitrate graph for that movie that wuld look a bit like this:

    In the stats file the bitrate recorded goes so high that the low motion scenes could suffer because too much attention is given to the fast motion scenes. To prevent this the compression setting can be set to "squash" the bitrate curve down to size. This in effect takes excess birate from the fast motion scenes and uses it to improve the low motion scenes. After a compression of about 20% the graph may look something like this:

    As you can see, the bitrate is still variable throughout but has been compressed so low motion scenes look better and high motion scenes don't look quite as amazing. Since increasing this number is essentially flattening out the bitrate curve too much will totally destroy the stats graph into a flat line. The trick is to use the minimum amont of compression needed to produce good low motion scenes. I usually use a setting between 10-30%.

    You may have noticed a small calculator button on the right of this compression setting. This is an automatic feature that tries to guess the best compression setting based on the information it has on your video. This is still an experimental feature. If you go to: Options > Preferences... and click on the tab called SBC you will see a variable there called the crosspoint. It's default value is 460 but changing this up and down will vary the ratio (crosspoint) between its known bitrate graph and the new value you want. You do not need to use this value at all, you can just set the compression how you like. The option was created merely for you to see if you could find automatic settings that worked every time. Nandubs creator suggests a crosspoint setting of 460 and some have suggested a value of half that for single CD rips. As for me I'm not sure, I prefer to go with my gut and guess the compression value myself.



    This helps to stop large jumps in bitrate that may look odd or just waste space. It is not a blur function and doesn't soften the image! Imagine it like this; the picture on the left is the normal stats graph and the picture on the right is after it has been smoothed:

    Leaving it at default setting is fine but I usually set it to about 2%. Some people seem to go as high as 5% but never use more than that! Adjusting the smoother isn't going to give significant increases in quality or compression. If you set it too high, like ths compression option it will just flatten out the 2-pass encoding information and make it useless!


    Luma Correction

    Scenes that contain a lot of contrast are difficult to compress. Mpeg compresses blurry or low contrast images better because there is less detail in them. If a scene that has a high contrast appears this option detects it and increases the bitrate to compensate. The threshold setting represents how high the lumina (or luminance i.e. brightness difference) needs to be before it will increase the bitrate for that scene. The Multiplier states by what degree the bitrate will be increased. The Nandub document suggests setting a Threshold of 10 and a Multiplier of 5 for most movies. For cartoons it suggested using Threshold 18 and Multiplier 8 since cartoons generally have more contrast and sharpness problems. Feel free to change these as you feel or use the default settings. You can also just turn the lumina correction off completely it will not harm your movie to do so. Playing with these settings will probably not significantly effect the final movie.


    End Credits

    This is optional. Before you decide to encode the movie in Nandub you can go to the end of it and find out how many frames there are for the end credits. Enter the number here and Nandub will automatically make sure that they are encoded at half the bitrate the rest of the movie uses. This can save you about 50MB of space to its well worth the effort. You do not need to alter any other settings because Nandub works all the calculations out itself.


    KF Boost

    The default setting is 0% but you can go upto about 5%. I'm not sure if it's worth using but I usually keep it 2%. I believe it's meant to boost the bitrate on the insertion of a keyframe so that the quality of the frame is slightly higher. I think the idea is that a better quality first keyframe will result in a better quality for the whole scene?


    Payback Delay

    Everyone seems to be happy with the default setting of 45 seconds but it can go upto 120 seconds. The time appears to be specifying how large a chunk of the movie Nandub is able to share out. If, for example, there is a lot of action in a movie it may be an idea to have a higher payback delay so that Nandub can take some bits from the lower bitrate parts and use them to make action scenes less blocky. I'm not completely sure how this works but it doesn't seem to make dramatic changes anyway so have a play with the setting and see what you think.


    High-Pass & Low-Pass

    This is almost the same as the Maximum and Minimum bitrate settings we already choose for the DivX codec. It sounds backwards because what it calls high is actually the lowest bitrate! What High-Pass really means is it must encode "higher" than the number you put in the High-Pass box. So if I put 200 in the High-Pass box the movie would only encode at a bitrate of 200kbps and higher! If I put 200kbps in the Low-Pass box it would only encode the movie at 200kbps and "lower"! Again, you do not need to be amazingly exact for this one! I usually use 2000kbps in the Low-Pass box and 600kbps in the High-Pass box, I think these usually do well for most movies. You can play around with these settings, as long as you don't put something silly like 1000kbps in the High-Pass box you shouldn't have any real problems with filesizes.



    I consider the gauge setting the most important setting. Most of the other settings can be more or less standardised. For example, you can use DRF of 2-8 on almost all movies. The keyframe and motion settings can be the same on all movies. The same luma correction can be used on all movies. The same crispiness modulation can be used on all movies. The same smoother settings can be used on all movies. The same payback delay can be used on all movies. Most movies will even have very similar high and low-pass settings or compression settings! But once all that is set up you can control the gauge settings to help control the final size of the movie. It only takes a little boost one way or the other to increase or decrease the final filesize.

    The gauge actually controls how many bits the DivX codec thinks are available for encoding each frame. Controlling the gauge is a bit like setting the bitrate for every frame of the movie. There are three settings: the Start; the Min and the Max values. Obviously the Min value is the minimum amount it will allow and the max is the most it will allow. The starting value is what it will begin with and it cannot be higher or lower than the other max or min values. Most people seem to get good results using a Start and Min of 30-40% and a Max of 80-100%. To increase the size of the final movie use a smaller Min and Max gauge number. To lower the size of the movie use a higher min and max gauge number changing in jumps of 10 or 20. Providing you set up the high and low pass and that your DivX bitrate settings are correct you shouldn't end up with a movie that is much smaller or larger than you intended.

    Phew! I hope this guide has helped to clarify the controls better. As I said there is no documentation on this thing so it hard to know exactly what is going on. So far these settings have been giving excellent results. Once you have finished setting up Nandub for the second pass you can finish your movie by choosing: File > Save As AVI...

    And hopefully, after another nights encoding you will have a movie to be proud of =o)

    Have fun...


    Duplication of links or content is strictly prohibited. (C) NICKY PAGE 2000