Nikon D90 Video "Stair-Step" Fix

Updated November 9th, 2008
An updated version of the AviSynth script has been uploaded. This updated version is based off work by hdkhang in the dvxuser.com forums, and has been optimized for improved rendering speed (from ~7fps to ~18fps).


Overview of the Problem
Lee Wilson did a fine job of explaining the problem on the dvxuser.com forums, so I'm just going to copy his explanation:
(Mostly guess work + some lies) The D90 seems to arrive at 1280 x 720p by firstly arriving at 1280 x 800p and then throwing away a horizontal line every 9 pixels. So we need to put back in a horizontal line every 9 pixels and then squeeze our new 1280 x 800p file down to 1280 x 720p.

Additional points:

a) I don't think it really works like this (above) but it is a convenient illustration.

b) As well as some horizontal lines being thrown away I can also see that some vertical lines are also thrown away (although I might have been fooled by compression artefacts) - but the horizontal lines are the most obvious.

c) The 'missing' line of pixels is not every 9 lines - it is more like 9 - 9 - 9 - 9 - 9 - 8 - 9 - 9 - so it throws a '8' at you every now and again.

That's the theory part finished with, I hope you enjoyed that, now take a break for 20 minutes - have a cup of coffee or maybe sleep for an hour or two.
The following video from Vimeo shows the problem quite well (be sure to view at full 720p resolution):


Notice the jagged edges which are especially visible in high-contrast areas such as the letters. Here is a screenshot detailing the problem:


Fixing the Problem
Fortunately Lee Wilson not only described the problem, but also determined a method by which it can be fixed (or at least improved greatly). If you would like a lot more detail about the fix, be sure to check out the dvxuser.com forum topic. Of course, the best way to fix this would be for Nikon to do it with a D90 firmware update (pretty please)! I'm assuming that is unlikely to happen soon (if ever), so in the meantime this method can be used.

There are a number of different programs you can use to fix this problem, including commercial applications like The Foundry's Nuke or Adobe After Effects. However, it is also possible to implement this fix using 100% free software, and that is the method I will detail. For this you will need the following:
  1. A Windows based PC
  2. AviSynth
  3. VirtualDubMod
  4. The AviSynth script I created (now tweaked by hdkhang for improved rendering speed!)
Obviously you first need to install both AviSynth and VirtualDubMod on your PC. Once that is done, download the AviSynth script anywhere on your computer (just be sure to remember where you put it!). Now follow these steps:
  1. Edit the destep.avs script in your favorite text editor. You will need to tell it where to find your D90 movie file. Let's assume you have a D90 video named DSC_0091.AVI and it is located on your computer in d:\d90_movies\ In the destep.avs file locate this line:
    video = "d:\movie.avi"
    You will need to edit that line to specify the location of your movie file, which would look like this:
    video = "d:\d90_movies\DSC_0091.AVI"
    Save the change you made, and continue to the next step.

  2. Start up VirtualDubMod and access the File > Open video file... menu item. In the file open dialog, select the destep.avs file.
     

  3. You will now see your video displayed in the VirtualDubMod window, with the fix applied! The last thing you need to do is save the new video. Access the File > Save As... menu item.

  4. From this dialog you can configure how the video will be saved. You should select Full Processing Mode from the Video mode selection list and then press the Change button to configure the compression you will use.

    There are a wide range of compression formats you can use, so I'll leave that for you to decide. When you press the Change button a dialog will appear that will allow you to select the compression format and configure options for the codec that you select. I personally have used Xvid and lagarith (if you want lossless) codecs with good results.
The Result
Saving the new video will take some time, so go out and shoot some more videos or photos with your D90 while you wait! Once it is done, your video file should look better, with the jagged edges removed. Here is an example before and after:


Special Thanks
Big thanks to Lee Wilson for discovering this method and posting information about it in the dvxuser.com forums.
I also must thank buildyo who posted the "magic code" in the dvxuser.com forums which I used as a basis for my AviSynth script (with a couple tweaks)
The updated AviSynth script with better rendering speed was created by hdkhang from the dvxuser.com forums

Tweaks and Other Updates
I am by no means an expert with AviSynth - in fact this is the first script I have ever written! It is certainly possible there is a better way to do this, so if you would like to contribute tweaks or any other improvements please e-mail them to me at dcgear@gmail.com