Log in

View Full Version : Script for custom aspect ratios in VCDs


TakuSkan
24th March 2006, 07:48
I wonder if someone in this forum can help me modify an AviSynth script that was worked out for me by Mr_Odwin in a recent thread in the 'Other MPEG1/2 encoder' forum here. (http://forum.doom9.org/showthread.php?p=800296#post800296) I seem to have run into a dead end in that forum, and would like to change the values to transcode 1.85:1 DVD files.

Mr_Odwin worked out the following script & the whole process for converting a 2.39:1 widescreen DVD MPEG-2 file I had uploaded here (http://rapidshare.de/files/15633289/Ap13_clip2.mpg.html) to a non-letterboxed VCD with the custom A/R of just the source video:

LoadPlugin("C:\PROGRA~1\GORDIA~\DGMPGDec\DGDecode.dll")

Video=mpeg2source("C:\<clip>\Ap13_clip2.d2v")
Audio=directshowsource("C:\<clip>\Ap13_clip2 T01 3_2ch 448Kbps DELAY 66ms.ac3")
Audiodub(Video,Audio)
DelayAudio(0.066)
crop(0,60,718,362)
lanczosresize(384,160)

I'm loading that script into TMPGEnc, setting it to output an MPEG-1 file with the video size set to 384x160 and aspect ratio set to 1:1 (VGA). That results in video that will play the full 800 pixel width of my old Toshiba Libretto 110CT's screen without letterboxing in the file. The d2v and ac3 files the script points to were created by loading the source video mpg file into DGIndex and saving the project.

The sub-notebook Libretto is only capable of running Windows Media Player v6 in Win98 & Win2000 with its little 233MHz CPU, and this has been the only way I've found to play widescreen videos to the full 800 pixel width of the screen.

Mr_Odwin wrote that script to remove the letterboxing from that test file made from a merged set of DVD vob files. Somehow he determined it had a 2.39:1 A/R, and came up with the crop(0,60,718,362) and lanczosresize(384,160) lines for the script. I'm hoping someone might explain how and why that works.

The script has been working for 2.39:1 DVDs, but now I need to alter the script to deal with 1.85:1 DVDs, and have no idea how Mr_Odwin figured out his magic, and now need to recreate it now with new values for 1.85:1 DVD files

I'd really appreciate any help at learning how to determine these values.

Thanks kindly,

TS

TakuSkan
25th March 2006, 04:02
Well... either this question is just too simplistic and dumb for these forums, it involves issues most people just don't often deal with, or I'm asking this in the wrong place. I tend to guess the 1st and perhaps last are in play here.. I'm just not getting any feedback.

I've been looking at the value of 384x160 for lanczosresize that Mr_Odwin worked out for the 2.39:1 video sample of mine, and have been playing with the default video sizes in TEMPGEnc.

Starting with a 384 pixel horizontal value as a target, it seems I would want to resize a 1.85:1 DVD file to a vertical pixel value of 208:

384/1.85 = 207.568 or ~ 208

And I see TMPGEnc offers a vertical 208 pixel value by default, so I'd think that would work.

I haven't been able to figure out values for 'crop' though. The only video tool with a GUI I can find to estimate cropping, or clipping the letterboxing out, is the 'clip frame' filter in TMPGEnc, tho' I guess I could save a frame to a bmp file, and have a look at it in Photoshop.

If I load the 2:39:1 test file I'd been working with in TMPGEnc and play with the 'clip frame' filter, I come up with a value of 60 pixels to clip from the top of the frame as Mr_Odwin did. But adjusting the bottom clipping value, the video starts getting clipped after 57 pixels. The value of 384 Mr_Odwin calculated doesn't jibe. I'd be getting this for a bottom cropping value:

480 - 57 = 423

I'll go ahead and modify those values in the above script, and run it on a few test files... and just see what comes out the other end.

It sure would be nice if someone could help point the way here though.

Thx,

TS

bagheera1
25th March 2006, 08:12
FitCD will do it for you, here is a script generated by Fit CD

# -= AviSynth v2.5.7.0 script by FitCD v1.2.8 =-

Mpeg2Source("Ap13_clip2.d2v")
BilinearResize(320,160,0,0,720,480)
AddBorders(16,32,16,48)
#Trim(0,300).FadeOut(150)

Download FitCD here (http://www.sysh.de/files/FitCD_v128.zip)

if you want a good program for finding cropping values, use VirtualDubMod (http://sourceforge.net/project/showfiles.php?group_id=65889)

load your file, select video->filters->add->null transform->OK
click cropping, adjust the video frame, write down the numbers for use in avisynth
Crop (clip, int left, int top, int width, int height, bool "align")
Crop (clip, int left, int top, int -right, int -bottom, bool "align")

TakuSkan
25th March 2006, 20:13
# -= AviSynth v2.5.7.0 script by FitCD v1.2.8 =-

Mpeg2Source("Ap13_clip2.d2v")
BilinearResize(320,160,0,0,720,480)
AddBorders(16,32,16,48)
#Trim(0,300).FadeOut(150)
I have been trying to get FitCD to create something that would work for me. I just loaded that Ap13_clip2.d2v file, but didn't come up with what you've got there.

One problem is that FitCD remembers settings I make that I don't understand, and then forget I've made. Then I have to delete the .ini file to start fresh. I'll gived your script a try.

But then I need to try FitCD on a test file GrapeClip2.mpg (http://rapidshare.de/files/16441575/GrapeClip2.mpg.html), or figure a script to deal with its 1.85:1 A/R.


if you want a good program for finding cropping values, use VirtualDubMod (http://sourceforge.net/project/showfiles.php?group_id=65889)
Terrific! :thanks: for pointing that out bagheera1. I'll give it a try.

TS

bagheera1
25th March 2006, 23:06
FitCD settings dont really need changed that much.
here is a screenshot of mine. I've underlined the important ones and pointed to the ones that I sometimes change.
I use bilinear because it slightly softens the image which gives better compression, and that means a higher bitrate and better quality.

http://img520.imageshack.us/img520/338/fitcdscreenshot9ql.th.jpg (http://img520.imageshack.us/my.php?image=fitcdscreenshot9ql.jpg)

By the way, you might want to use Nicaudio (http://forum.doom9.org/showthread.php?t=108112) instead of directshowsource, its probably more reliable (I try to aviod directshow if posible).

TakuSkan
26th March 2006, 07:10
here is a screenshot of mine
I just loaded your script into VDub, and it complained about 'Invalid Arguments' in the BilinearResize function. Something's out of whack somewhere at your end or mine.

Also.. looking at the value you have for BilinearResize, it appears to be outputing to a 320x160 pixel output, not 384x160. That was a problem I had with FitCD. I couldn't tweak that 1st horizontal value.

I know about nothing about these scrpits, but your script doesn't seem to address the issue I had with cropping letterboxing from widescreen MPEG-2 DVD files. The script I've been using manages to crop out the letterboxing from the original DVD video. But I sure don't understand why with the values of:

crop(0,60,718,362)
And your script is trying to recreate what I've already accomplished dealing with a 2.39:1 source.

The AVISynth script I originally posted above deals with 2:39:1 fine. But I need to tweak it to process 1.85:1 letterboxed video. I can set the script to resize my new 1.85:1 GrapeClip2.mpg (http://rapidshare.de/files/16441575/GrapeClip2.mpg.html) 384x208 pixel test file, and it looks great in VDub by setting the line:

lanczosresize(384,208)
But because I don't have the 'crop' values set right, the script outputs a file that plays back in WMP v6 in a 4:3 A/R. Even though WMP v9 plays its proper widescreen A/R.

BTW: I uploaded the wrong test file in my previous post. I've fixed that now.

TS

bagheera1
26th March 2006, 17:07
I just tried the script I sent jou, and it works fine for me. Is it VirtualDub complaning or avisynth?

I think I misunderstood your origional problem. Are you going to watch this stuff on a TV or your computer?
If its your computer and you want a VCD format just set your overscan to 0 in FitCD and dont include the addborders line in the script it generates.
If its your TV, the tv will display the picture squished unless you include the letterbox borders or crop off some of the picture to get the correct 4/3 ratio (I hope that is not what you want to do).

-----------------------
I've just reread everything, and I now see that you want to watch it on a laptop, not a TV. The word VCD in your post through me. what you want is an MPEG1 with no borders, but in the correct aspect ratio right?

If this is the case, load the origional clip in vdubmod use nulltransform to get crop values, make an avs with the crop(left,top,-right,-bottom) save it. Open the MPEG with fitcd and see if anamorphic is checked, then open the avs you just created, check or uncheck the anamorphic as in the origional, select vcd as the destination (do not check anamorphic in destination), select 0 blocks overscan, move slider to 16 macroblocks optimized, crop to accurate, both crop sliders to 2, select a resizer. then copy the resize line in the displayed script and paste in your origional avs after the crop line. that should be it.

see how this works out.

TakuSkan
29th March 2006, 08:20
Are you going to watch this stuff on a TV or your computer?
The objective is to transcode a widescreen MPEG-2 DVD movie to a non-letterboxed, non-anamorphic video file with a 384 pixel horizontal width, and a corrsponding vertical pixel value. The file must play in Windows Media Player v6, and fill the entire screen horizontally. That's what I see as the requirements to get transcoded DVD movies to play on my old Toshiba Libretto 110CT with its 233MHz CPU.

If its your computer and you want a VCD format just set your overscan to 0 in FitCD and dont include the addborders line in the script it generates.
But the horizontal pixel value of the anamorphic video source also has to be stretched to create non-anamorphic video content that will display properly in WMP v6.

I've just reread everything, and I now see that you want to watch it on a laptop, not a TV. The word VCD in your post through me. what you want is an MPEG1 with no borders, but in the correct aspect ratio right?
Yes... I'm sorry... it's not technically a VCD, but I have to start with a VCD template in TMPGEnc, and then modify it to produce the files I need.

If this is the case, load the origional clip in vdubmod use nulltransform to get crop values
Okay... I'm going to start over and compare your process to the one Mr_Odwin gave me based on the 2.39:1 anamorphic Ap13_clip2.mpg clip I uploaded here (http://rapidshare.de/files/15633289/Ap13_clip2.mpg.html).

make an avs with the crop(left,top,-right,-bottom) save it.
Okay... I had to change 'Video=mpeg2source' from Mr_Odwin's script (http://forum.doom9.org/showthread.php?p=800296#post800296) to 'DirectShowSource', and preface it with the path to DGDecode.dll before VDub stopped complaining. From the values I got from VDub, here's what I had for a script at that point:

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
DirectShowSource("D:\Videos\Rips\Ap13_clip2.mpg")
crop(0,60,-0,-60)
Open the MPEG with fitcd and see if anamorphic is checked, then open the avs you just created, check or uncheck the anamorphic as in the original, select vcd as the destination (do not check anamorphic in destination), select 0 blocks overscan, move slider to 16 macroblocks optimized, crop to accurate, both crop sliders to 2, select a resizer.
Okay... the last part there, "select a resizer" is a problem. Rezize to what?

Mr_Odwin's script that works for me resized the horizontal value to 384, and vertical to 160 to deal with stretching the anamorphic source to a non-anamorphic one. FitCD doesn't allow reseting the default size of 352 horizontal value to anything else. If I start with 352h and want to crop to a 2:39:1 A/R, I'd have to set 147v, as 352/2.39 = 147.280. I'd end up cropping to: 352x147

The problem there is going to be when I load the script into TMPGEnc wizard, choose the VCD option, and have to duplicate that 352x147 setting. TMPGEnc will complain that 147 resolution is 'illegal'.

Going with 144 works, and I end up with a full script as follows:

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
DirectShowSource("D:\Videos\Rips\Ap13_clip2.mpg")
crop(0,60,-0,-60)
(352,144,0,0,720,360)
But the video and audio in TMPGEnc's output file ends up out of sync. Mr_Odwin's method of using a DGIndex d2v project file and demuxed audio file with specified audio delay worked well.

Again, after having Mr-Odwin's successful script for 2.39:1 video, my end objective now is to find a process for transcoding 1.85:1 widescreen DVD movies to these MPEG-1 with this custom A/R for my little Libretto. And getting a nbit larger 384h A/R get's me a bit higher resolution. So far I don't see the FitCD process as working very well.

then copy the resize line in the displayed script and paste in your origional avs after the crop line. that should be it.
Well... except for loading the script into TMPGEnc and processing it as per Mr-Odwin's instructions here. (http://forum.doom9.org/showthread.php?p=800296#post800296)

bagheera1
29th March 2006, 16:18
your sync problem is most likely from DirectShowSource.
from now on dont use it anymore.
open mpeg2 files with
__________________________________________________
mpeg2source("name.d2v")
nicAc3source("ac3_name.ac3,2) #(the 2 indicates, downmix to 2 channels)
audiodub(v,a)
delayaudio(0.000) #taken from the ac3 name in miliseconds
crop(left,top,-right,-bottom) #crop off any black borders

######## Include this section only if needed ########
AssumeTFF()#.SeparateFields()
telecide(guide=1,post=2)
decimate()
########################################

lanczosresize(800,height)
__________________________________________________

to calculate height,
height=width/aspect ratio
round height to a multiple of 16

example:
800/1.85=432.4324
432.4324/16=27.0270
so 27*16=432
lanczosresize(800,432)

read about the telecide section in DecombTutorial.html, it comes with dgmpgdec

I almost forgot, in tmpgenc make sure you select mpeg-1 system (automatic).
it can be found by, settings button, system tab, streamtype dropdown list