Here's a batch that crops any video to 128x128 cleanly. Just change the vdub variable to suit. I just right click on a vid, Open With > crop.bat
crop.bat
- Code: Select all
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"
This uses VirtualDub's CLI to create, invoke, then delete a script- saving the resized AVI in a new directory 'cropped', in the source directory. This suited me but you change it if you want.
I use Huffyuv lossless compression rather than uncompressed. Download it here
http://neuron2.net/www.math.berkeley.edu/benrg/huffyuv.html, or rem that line. It is very fast though, and can save you big bytes. Free too.
Here's another one that will resize your vid to 128 wide, retain the aspect ratio and letterbox the remainder. Good for movies if you don't want to miss out on the side bits (keeps file size down too a bit too).
letterbox.bat
- Code: Select all
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");
%vdub% /i "%~dpn1.script" %1
del "%~dpn1.script"
I hope this helps somebody out there,
cheers,
- daz