VirtualDub corrections

From S1MP3 Wiki

Jump to: navigation, search

VirtualDub corrections Step-by-Step

  • Download and unpack VirtualDub binaries : http://virtualdub.sourceforge.net/
  • Run VirtualDub.exe
  • Open your video (File, Open video file)
  • Press CTRL+F to access the video Filters screen.
  • Click Add..., and select sharpen filter. Set it as you like. (I like setting it to maximum)
    • Now, if your video is big enough, you can first add the 2:1 reduction (high quality) filter, which will reduce the video size in half with a good quality.
  • Click Add... again, and select the resize filter. Set the new width and height as the target size of your player screen (96x64, 128x96, etc); for Filter mode you'll usually prefer Bicubic, but click the Show preview button and change the settings for visually comparing the difference. Click OK when done.
  • You'll see the resize filter was added to the Filters list, showing the initial and final video size. Take note of the original video size, you will need to know this later.
  • Select the resize filter you have just set, and click the Cropping... button. You'll see your video and some offset settings.
    • You will need to change the offset settings to crop your video to a screen ratio that matches your player (you'll want a 3:2 ratio, while most sources are in 4:3 or others screen formats)
    • Give the two of the offsets a value(prefer X1 and X2), you can set any value you find best.
    • Now, to discover the sum of the other two by this formula: H - [(W - X1 - X2).3/4] = Y1 + Y2, Where:
      • X1 and X2 are the X offsets
      • Y1 and Y2 are the Y offsets
      • H is the original video Height
      • W is the original video Weight
    • Make sure this formula is followed, or you'll end up with poor videos
  • Press CTRL+P to open the video compression screen. It is recommended you select the Uncompressed RGB/YCbCr if you can, which will make processing faster and keep the video quality, but will produce huge files (~300Mb for 10min). Click OK after done.
  • Now you are ready to save the file, press F7 and choose a new file to save as. After that is done, you can use the MP3 Player Utilities to produce an AMV or MTV video file from the AVI we created. (TODO: explain sound processing steps).

Test results

In the examples below, I used VirtualDub to rescale (and crop) the video (to 128x96, my players max video resolution). The images were scaled 2x for better viewing.

Just scaled (Precise Bicubic A=1) in VirtualDub (Lossless IYUV):


Encoded to AMV (128x96 high fps) from the previous rescaled video
Encoded to AMV (128x96 high fps) directly from original (720x480)


The AMV files:

Batch files

This Batch file allows you to simply right click on a video filename, and Open With > crop.bat to resize rather than openning VirtualDub and manually calculating the crop area for each video before converting to AMV format.

It uses VirtualDub's CLI (Command Line Interface) to create, invoke, then delete a script which saves the resized AVI in a new directory.

Before you use:

  • Point to VirtualDub, edit this line:

set vdub=C:\vdub\vdub.exe

  • Set destination directory:

set destdir=%~dp1cropped

Left as is, it will make the directory 'cropped' within the source directory and save the resized AVI there. This may suit you, but you can changed it to set destdir=C:\videos\cropped or whatever.

  • Download Huffyuv lossless video codec. Very fast, and can save you big bytes compared to uncompressed.

If you don't want to, or can't, add rem to the start of this line:
echo>>"%~dpn1.script" vd.video.SetCompression(0x75796668,0,10000,0);


crop.bat

cls
set vdub=C:\vdub\vdub.exe
set destdir=%~dp1cropped

if not exist "%destdir%" mkdir "%destdir%"

echo>"%~dpn1.script" declare vd = VirtualDub;
echo>>"%~dpn1.script" vd.Open(vd.params[0]);

rem huffyuv lossless compression
rem http://neuron2.net/www.math.berkeley.edu/benrg/huffyuv.html
echo>>"%~dpn1.script" vd.video.SetCompression(0x75796668,0,10000,0);

echo>>"%~dpn1.script" vd.video.filters.Clear();
echo>>"%~dpn1.script" declare w = vd.video.width;
echo>>"%~dpn1.script" declare h = vd.video.height;
echo>>"%~dpn1.script" declare i = vd.video.filters.Add("resize");
echo>>"%~dpn1.script" vd.video.filters.instance[i].SetClipping((w-h)/2,0,(w-h)/2,0);
rem - or, if source is tall...
rem echo>>"%~dpn1.script" vd.video.filters.instance[i].SetClipping(0,(h-w)/2,0,(h-w)/2);

echo>>"%~dpn1.script" vd.video.filters.instance[i].Config(128, 128, 4);
echo>>"%~dpn1.script" vd.SaveAVI(U"%destdir%\%~n1.avi");

%vdub% /i "%~dpn1.script" %1
del "%~dpn1.script"


The following batch file works similar, resizing to 128x128, but will retain the original aspect ratio and letterbox the remainder. Good for movies where you don't want to miss out on the edges where you would when cropping (keeps file size down a bit too).

letterbox.bat

cls
set vdub=C:\vdub\vdub.exe
set destdir=%~dp1letterbox

if not exist "%destdir%" mkdir "%destdir%"

echo> "%~dpn1.script" declare vd = VirtualDub;
echo>>"%~dpn1.script" vd.Open(vd.params[0]);

rem huffyuv lossless compression
rem http://neuron2.net/www.math.berkeley.edu/benrg/huffyuv.html
echo>>"%~dpn1.script" vd.video.SetCompression(0x75796668,0,10000,0);

echo>>"%~dpn1.script" vd.video.filters.Clear();
echo>>"%~dpn1.script" declare w = vd.video.width;
echo>>"%~dpn1.script" declare h = vd.video.height;
echo>>"%~dpn1.script" declare i = vd.video.filters.Add("resize");
echo>>"%~dp1%~n1.script" vd.video.filters.instance[i].Config(128, h*128.0/w, 4, 128, 128, 0);
rem - or, if source is tall...
rem echo>>"%~dp1%~n1.script" vd.video.filters.instance[i].Config(w*128.0/h, 128, 4, 128, 128, 0);

echo>>"%~dpn1.script" vd.SaveAVI(U"%destdir%\%~n1.avi");

[[Category:Simple video formats]]
%vdub% /i "%~dpn1.script" %1
del "%~dpn1.script"
Personal tools
about this site
Advertisement