ホスティング レンタルサーバ レンタルサーバー

u n d e r c u t ' s   p u b l i c   d o m a i n
Page Last Updated 03/25/2003

Back to undercut's homepage
Nandub_OnePass
日本語 · articles · fansubs · Nandub_OnePass · WebFServe · MS-MPEG4 · download · email

English · 日本語

Nandub_OnePass 2.18 (http://www.undercut.org/Nandub_OnePass/)
Modified Nandub 0.28 (http://www.nandub.org/)
Modified VirtualDub 1.4d (http://www.virtualdub.org/)

Index


Download

FilenameSizeLast Modified
Nandub_OnePass_2.18-0.28-binary.rar893 KB02/10/2003 3:30 pm
Nandub_OnePass_2.18-0.28-source.rar1876 KB02/10/2003 3:31 pm


What's New

2003-02-10: Version 2.18-028

New feature OP/ED Saver added. See here for details. It is similar to the End Credits feature of original Nandub, but more functional. In the true anime spirit, there're spaces for both opening and ending sequences ;-)

Updated the antishit to be disabled when gauge gets too low to accommodate the end credits feature. Previously, purposely dropped frames (due to low gauge level) were detected as errors.

2001-12-01: Version 2.17-028

Critical bug fix. Min/Max CL settings weren't being saved in the last version.

2001-11-09: Version 2.16-028

Pure cosmetic changes. Dialogues have been simplified with all 2 Pass related items removed. CL settings have been moved to the main tab to reduce the tabs to just 2.

2001-10-12: Version 2.15-028

Reworked Anti-shit (KF). It now applies the same kind of loop that's being used for Anti-shit (CL). That is, it will reencode KFs at progressively higher CL until it does not see any improvements. It also now checks for shit present on KFs. This has great effect on eliminating the bad frames from repeatedly occuring in long sequence. See the Anti-Shit (KF) section for more detail.

A minor improvement in both antishit (modulated headroom when checking for improvements in reencoded frames) and updated default config.

2001-09-24: Version 2.13-028

New default config which minimizes deviation and increases filesize predictability. You can now use the calculator and get predictable filesize in one pass. Quality is about the same as the old config. This was realized after experimenting with DivX4 and checking the codes of Nandub regarding behavior of Payback Delay option. I think now this version and DivX4's One Pass mode is very similar.

2001-07-09: Version 2.12-0.28

Issue with max CL of KFs from external SCD being one less than actual setting fixed.


What is it

Main purpose is to optimize Nandub for use in One Pass encoding as well as introducing features to improve the process.

But why use one pass encoding at all and not two pass? I think it depends on trade-offs and your taste. Some will claim that two pass encoding will always result in better quality, but that's completely subjective and often false. If you have two MS-MPEG4 video both of same size, one done in one pass and other in two pass, it's not possible to say one is conclusively better than the other. Technically, there are no wasted bits in both of these files. All the bits are used up somewhere. Question is how well and effectively the bits are used up to suit our eye.

It is possible to have enough tweaks for one pass that it gets the job done and with excellent result. I think many experts agree that best feature of Nandub is how it can control the MS-MPEG4 codec like limiting DRFs and controlling gauge. Two passes are not needed to take advantage of these feature which alone can provide VBR encoding with fair filesize predictability. Nandub also introduced the Antishit which eliminates much of encoding bugs present in MS-MPEG4 codec as well as advanced SCD superior to others such as DivX4 or AviUtil/m4c. Those features are also retained and enhanced in this version.

Recent popularity of DivX 4 in its one pass mode should be a good proof of utility value for one pass encodings. I have done some tests of my own to compare the DivX 4 in one pass and Nandub_OnePass, and I like DivX 4 more and more as new versions come out. DivX 4 should eventually take over Nandub, since Microsoft isn't likely to release any new codec to be used in AVI but DivX 4 has a new version every month. Its One Pass mode is perfect for those that wants to get great video without fiddling around too much. It's very simple and default settings give excellent result. (I would use default over most other user suggested settings) Just set the bitrate and go. Everyone is happy.

But for now, MS-MPEG4 is still better at medium to low bitrate. For high bitrate (over 1000) I think DivX 4 is better already. This tool attempts to allow those that wants to do similar thing as DivX 4 one pass mode with MS-MPEG4 to take advantage of the features introduced in Nandub to accomplish it with some new features and optimizations aimed for one pass encoding.


Installation

Copy Nandub_OnePass.exe to your existing VirtualDub/Nandub directory.


Setup for One Pass encoding

In short: Launch Nandub_OnePass, load source AVI, set audio compression, use the bitrate calculator to assign the video bitrate, then do Save AVI.

More detail: Max CL and Bitrate are critical settings that should be customized. (more detail below) Keyframe, scene detection, and anti-shit settings can be customized as needed, but not critical. Though make sure to check the Scene tab in Preferences to make sure it's set to some reasonable value. (206 should be best for most)

Once the settings are set, do Save AVI as you would with normal VirtualDub.

Tips for AVISynth

Nandub_OnePass is based on an older VirtualDub which does not detect YUV inputs properly and so requires RGB input. To use it with AVISynth, you will need to specify ConvertToRGB() at the end of your script. You can then set processing mode to Normal recompress if you do not use VirtualDub filters which may be slightly faster than Full processing mode. However, you cannot use Fast recompress. Nandub_OnePass (or Nandub for that matter) will not work as intended in this mode. This is why I haven't taken the time to fix the problem since VirtualDub will need to convert to RGB internally anyway in these modes.

More details on Compression Levels and Bitrate

Set the Max CL value. Keep the Min at 2x. (low motion quality will be terrible otherwise) Think of this as the worst quality you will allow during fast motion scenes. With higher max CL, quality during fast motion scene will degrade but will save a lot of space for those scene. The saved space will be used for more bits in low motion scenes. Higher max CL can be used with higher resolution since compression artifacts won't get zoomed up as much during playback, and generally higher resolution video is more compressable. (less detail per pixel)

So good max CL to use will depend largely on the bitrate and resolution. Goal is to hit on a good balance between quality of fast motion and low motion. Below is the table I use to determine the optimum max CL. If using aspect other than 4:3, use the one with closest pixel count:

Resolution:Bitrate

600
700
800
900
1000
320x240 (76800)
6x
5x
4x
3x
2x
384x288 (110592)

7x

6x

5x

4x

3x

448x336 (150528)
8x
7x
6x
5x
4x
480x360 (172800)

9x

8x

7x

6x

5x

512x384 (196608)
10x
9x
8x
7x
6x
544x408 (221952)
11x
10x
9x
8x
7x
576x432 (248832)

12x

11x

10x

9x

8x

608x456 (277248)
13x
12x
11x
10x
9x
640x480 (307200)
14x
13x
12x
11x
10x


Differences from Nandub

No Larger KF than delta

This feature is enabled when internal SCD is enabled (by setting it less than 100) and Quality Control is set to full. When KF is inserted by any SCD (internal or external), it checks to see if delta frame would result in smaller frame. If delta is smaller, it reencodes the frame as delta. It makes sure that KFs are inserted in the most effective way for MPEG4.

It does not check KFs inserted by codec's regular interval. This function will weed out most of them otherwise.

It is recommended that Space KF setting be set much lower (3 to 6) with this feature enabled because it is now better for a lot of scene changes to be triggered than too few. This function will weed out the bad ones.

This feature is also very useful in examining the SCD settings/algorithms. It appears that VirtualDub's built-in SCD does excellent job at about 206, and Nandub's Internal SCD is not as effective. It often result in larger KF than delta. Surprisingly, I also noticed that codec's built-in SCD (which gets force enabled with bitrate lower than 460, no way to turn it off) is not so bad. The main problem is it inserts just too many resulting in often jerky playback. BTW, this feature does not check these KFs since it's not possible to tell apart wether it came from regular interval or codec's SCD. So don't use bitrate lower than 460.

Anti-shit (CL)

"Minimum Quality" box has been replaced with "Anit-shit (CL)". (Compression Level) It's sole purpose is to eliminate luma-inverted block errors. (I'm sure you've seen those ugly squares that show up on edges of highly contrasting colors) This is used first before the traditional Anti-shit (using KF) is checked.

This feature has been imported in Nandub since version 0.26, except this version works independent from the traditional anti-shit. (in place of removed Minimum Quality) In normal Nandub, you need to enable Minimum Quality to enable this feature.

Here's how it works: If the lowest PSNR of a frame is found to be too low, it'll reencode the frame at progressively higher CL until the PSNR doesn't show improvement. Idea behind it is that the luma-inverted block errors show up less and less as the CL goes up. If the PSNR doesn't improve as CL goes up, then it's highly unlikely to be caused by this error so it'll keep the former frame. If a frame doesn't contain this error, PSNR would go down as CL goes up due to higher compression.

This method is much less risky than original anti-shit, and in fact should not hurt the video at all no matter how high you set it at because if PSNR doesn't improve, it won't change anything.

Here it is in action:

00174934 4:41:41 AM [Nandub-u] --> PSNR was 42.21(16.95). Reencoding at CL 3...
00174935 4:41:41 AM [Nandub-u] --> PSNR was 46.36(30.52). Reencoding at CL 4...
00174936 4:41:41 AM [Nandub-u] --> PSNR was 46.09(29.58), Going with CL 3...
00174937 4:41:41 AM [Nandub-u] df:042713, 02034 bytes, 3x (2.99x), R:0575, BR:35.00%-(35.00%), D: 24.30Mb, PSNR=46.36(30.52)

00175165 4:41:55 AM [Nandub-u] --> PSNR was 42.18(15.00). Reencoding at CL 3...
00175166 4:41:55 AM [Nandub-u] --> PSNR was 44.51(26.97). Reencoding at CL 4...
00175167 4:41:55 AM [Nandub-u] --> PSNR was 43.38(30.46). Reencoding at CL 5...
00175168 4:41:55 AM [Nandub-u] --> PSNR was 42.86(28.79), Going with CL 4...
00175169 4:41:55 AM [Nandub-u] df:042938, 05698 bytes, 4x (2.99x), R:0575, BR:35.00%+(35.00%), D: 24.51Mb, PSNR=43.38(30.46)

00178675 4:45:17 AM [Nandub-u] --> PSNR was 39.62(16.29). Reencoding at CL 4...
00178676 4:45:17 AM [Nandub-u] --> PSNR was 39.23(26.54). Reencoding at CL 5...
00178677 4:45:17 AM [Nandub-u] --> PSNR was 39.00(26.04), Going with CL 4...
00178678 4:45:17 AM [Nandub-u] df:046425, 05873 bytes, 4x (2.94x), R:0575, BR:35.00%+(35.00%), D: 27.47Mb, PSNR=39.23(26.54)

The first line on top is result from frame encoded at 2x. (it's one CL less than what it's going to reencode at) See how PSNR increased when it reencoded it at 3x instead of 2x? It should have decreased if it wasn't for the luma inverted block error.

Anti-shit CL based modulation

"Motion Modulation" of Anti-shit has been changed to "Motion/CL Modulation". This adds CL based modulation of the Anit-shit values (DRF and KF), but only when doing one pass encoding. In two pass, Nandub does Motion Modulation already. Here's how it works: When checking each frame for error, it decreases the Anti-shit value by (CL - 2) * (1 + CL_Modulation/100) if it's not set at 0. So higher the CL on the frame, less likely that the frame will be detected as error. (again based on the idea that luma inverted errors appear less on high CL, and that higher CL results in naturally lower PSNR which are not errors) Some examples:

Anit-shit: 24
Motion/DRF Modulation: 50%

Frame: 2x, 24 - (2 - 2) * 1.50 = 24
Frame: 3x, 24 - (3 - 2) * 1.50 = 22.5
Frame: 4x, 24 - (4 - 2) * 1.50 = 21
Frame: 5x, 24 - (5 - 2) * 1.50 = 19.5
Frame: 8x, 24 - (8 - 2) * 1.50 = 15

The result shown is what's used as the Anit-shit to compare against the frame's PSNR. And as usual, if PSNR is below it, it'll detect it as error. With this feature, it's OK to set the anti-shit high (18-24), since frames that are highly compressed won't be detected as errors.

Anti-shit (KF) Improvements

Regular Anti-shit (using KF) has been upgraded to do the similar loop as featured in Anti-shit (using CL) above. That is, it will reencode KFs at progressively higher CL until it does not see any improvements.

It also checks for shit present on KFs. Since the original Nandub does not have this kind of anitshit, it was not possible to fix shit on KFs. With this new method, it can now eliminate shit on KFs as well which seems to happen quite often on KF at CL 2x or 3x. This has great effect on eliminating the bad frames from repeatedly occuring in long sequence. When such sequence occur, it is generally caused by codec inserted KFs at low CL.

Anti-shit (KF) and Anti-shit (CL) works great in combination. First, CL method would be used. Then the frame will be sent to KF method if it still fails to meet the quality. It is recommended that KF value be set lower than CL value because KF method is more risky and you do not want it to be mistriggered. (you get unnecessary KFs) CL method is almost harmless even when mistriggered.

OP/ED Saver

Idea is similar to the end credits feature found in original Nandub. OP and ED sets both do the same thing. It takes a range of frames (specified by the absolute position in the movie, not relative to starting position of encode) for the scene instead of just the beginning frame like the original, which is useful for anime but works just as well on most movies.

Purpose of this routine is not to use less bitrate but is to stay within the specified bitrate. It does this by setting the minimum gauge to 0. MS-MPEG4 (like Divx5 even with GMC enabled) have a lot of problem encoding scrolling credits. It will often cause huge oversize deviation. By setting minimum gauge to 0 at such end credits scene, it will contain the deviation at those scenes by dropping frames if necessary.

This routine also has a excellent side effect of absorbing existing deviation already present when this kicks in. This is very effective when the ED scene comes toward the end of an encode, which is where they usually are.

Default settings

Default values are set for one pass encoding. Audio interleving defaults to 500ms instead of 1 frame. (that's from VirtualDub) Default layout is set same as original VirtualDub. (no vertical/swapped preview windows)



Copyright © 2000-2003 Undercut.org. All rights reserved.
Managed by Site Compiler