Log in

View Full Version : Script for DVD to *VCD


divxdede
31st August 2004, 12:45
Hello, everybody.
I posted my script on some french forums but since i haven't any response i will ask at the source :)

I'm learning Avisynth script since i'm currently developp a little project.

I'm working especially on a script that do all the job for manage DVD source to a destination on VCD formats (VCD/SVCD/CVD/SVCD-HR)

My Script should manage the AutoCrop, de-anamorphic process, add borders, etc...

I wrote my first version, and i want to know if it is conform with all requirement expected for a script like it (aspect ratio,output size,filters,etc..)

The script (for a source DVD PAL 16:9)


# Chargement des Plugins
# ----------------------
LoadPlugin("****\MPEG2Dec3.dll")
LoadPlugin("****\AutoCrop.dll")
LoadPlugin("****\UnDot.dll")
LoadPlugin("****\asharp.dll")
LoadPlugin("****\FluxSmooth.dll")
LoadPlugin("****\blockbuster.dll")


# Chargement de la vidéo source
# -----------------------------
Video=Mpeg2Source("****\xxxx.d2v", idct=2 )


# DVD PAL 16:9 ==> SVCD PAL
# -------------------------
Return Video.xVCDResize(480,576,1.77778)

# Fonction de Resize vers un support VCD / SCVD / xVCD
# ----------------------------------------------------
function xVCDResize(clip sourceClip,int "width",int "height",float "dvdRatio")
{

# Crop la source
#
croppedClip = sourceClip.Autocrop(0,16,16,0,0,0,0,30,7,0,-1)

croppedClip = croppedClip.Undot()
croppedClip = croppedClip.asharp(2,4,0.25)


# R = (R' / R0) * (16/9)
# ----------------------
# R0 : Rapport L/H du support DVD (Ratio de la source anamorphosée)
# R : Rapport L/H vidéo source réél (Aspect Ratio)
# R' : Rapport L/H vidéo source une fois croppée (toujours anamorphosée)
# ----------------------
# Ex : + Dvd 16:9 720*576 PAL
# ==> R0 = 720 / 576 = 1.25
# + Une fois cropée, la vidéo anamorphosée à une taille de 720 * 386
# ==> R' = 704 / 432 = 1.6296
#
# ==> R = ( 1.6296 / 1.25 ) * (16/9) = 2.32 =~ 2.35
#

R0 = sourceClip.width / sourceClip.height

RPrime = croppedClip.width / croppedClip.height

Ratio = ( RPrime / R0 ) * dvdRatio

# Les télévisions affiche en general assez mal les 2er blocs 8x8 de chaque coté de l'écran
#
resizeWidth = width - 32

# Calcul de la hauteur en fonction de la largeur
#
resizeHeight = Ceil( resizeWidth / Ratio )
resizeHeight = (resizeHeight / 8) == 0 ? (resizeHeight) : Ceil( ( resizeHeight / 8 ) * 8 )

# Desanamorphose du film
#
desanamorphedClip = croppedClip.BilinearResize( resizeWidth , resizeHeight )
desanamorphedClip = desanamorphedClip.undot()
desanamorphedClip = desanamorphedClip.FluxSmooth(5,3)
desanamorphedClip = desanamorphedClip.Blockbuster(method="noise",detail_min=1,detail_max=10,variance=0.8 )
desanamorphedClip = desanamorphedClip.Undot()


# Ajout des Bords manquant
#
horizontalBorder = Ceil( ( height - desanamorphedClip.height ) / 2 )
horizontalGap = height - desanamorphedClip.height - (horizontalBorder * 2)
verticalGap = width - desanamorphedClip.width - 32

Result = desanamorphedClip.AddBorders(16 + verticalGap,horizontalBorder + horizontalGap , 16 , horizontalBorder) Result = Result.limiter()
# ConvertToYUY2() # necessaire pour CCE
return Result
}


The function xVCDResize manage all filters/resize process with only theses 3 parameters
1. The output size (here 480x576 ==> SVCD)
2. The DVD source mode 4:3 or 16:9 ( here 16:9 ==> 1.77778)

with theses mecanism, this script should be adaptative from any DVD source

By example, if we have a DVD PAL 4:3 and want a VCD PAL we should modify the function call by this


Return Video.xVCDResize(352,288,1.33333)


I'm not an expert on avisynth, then if somebody can test and say me if someone goes wrong with my script, all remarks and comments will be appreciate.

Thanks in advance.
divxdede