View Full Version : I think avisynth needs new function
erspicu
3rd July 2007, 04:54
AddAR info to Clip Properties ?
I have problem getting correct CLIP AR.
Does anyone know how to do ?
http://forum.doom9.org/showthread.php?t=124144
Richard Berg
3rd July 2007, 08:27
Here's a function I use, maybe you'll find it useful:
function ResizeAR(clip c, int "dest_x", int "dest_y", string "ar")
{
# parameters
Assert(!ar.Defined || ar.LCase == "sar" || ar.LCase == "dar",
\ "rb-ResizeAR: If defined, 'print' must be 'sar' or 'dar'.")
dest_x = default(dest_x, c.width)
dest_y = default(dest_y, c.height)
# calculations
dest_ar = float(dest_x)/dest_y
dar = (float(c.width)/c.height) * (4320./4739)
sar = dar / dest_ar
# setup MeGUI - TODO: use nicefps()
global MeGUI_darx = round(dar * 1000)
global MeGUI_dary = 1000
# output
out = c.LimitedSharpen(dest_x = dest_x, dest_y = dest_y)
return !ar.Defined ? out : out.SubTitle(ar + ": " + string(eval(ar)))
}
erspicu
3rd July 2007, 11:09
Here's a function I use, maybe you'll find it useful:
}[/code]
I want to get really ar info not calculating or setup ar...
Like VOB file, it's 720x480 pixel,but there is spec AR
(16:9 or 4:3 ) .
so 720x480 must be show as 640x480 or 640x 360.
but if I use directshow
DirectShowSource("someone.vob",fps=15,convertfps=true)
w = float (Width)
h = float (Height)
rate = int ((w / h) * 1000)
srate = w / h
I will get srate = 720 / 480 = 1.5,not 1.33 or 1.85 ..
ex vob file,somefile alose have setup it's speciall AR.
so my avs script will error .
w = float (Width)
h = float (Height)
rate = int ((w / h) * 1000)
srate = w / h
( rate >= 1740 && rate <= 1800 )? Eval("""
LanczosResize(480,272)
"""):Eval("""
""")
( rate < 1740 )? Eval("""
new_w = srate * 272
new_w = int (new_w)
new_w = new_w - (new_w%4)
LanczosResize(new_w,272)
add_w = (480 - new_w)/ 2
AddBorders(add_w,0,add_w,0)
"""):Eval("""
""")
( rate > 1800 )? Eval("""
new_h = 480 / srate
new_h = int (new_h)
new_h = new_h - (new_h%4)
LanczosResize(480,new_h)
add_h = (272 - new_h)/ 2
AddBorders(0,add_h,0,add_h)
"""):Eval("""
""")
this can auto add boarder to make a right size aspect.
but some movies files like vob .mpg(mpeg2),it has it specially
AR (720x480 by pixel , it's 3:2 ,but in fact it's 4:3 or 16:9).
so my avisynth script is lost right aspect.
Fizick
3rd July 2007, 20:15
probably you may make a request for avisynth 2.6 or 3.0 to store AR somewhere as video property.
it is sort of non-square pixels.
But it is not very clear task.
Assume somebody crop this video. What will be AR?
Richard Berg
4th July 2007, 21:43
Crop does not have enough info to change AR correctly, unless we add another parameter. It has to know whether you are cropping out part of the active picture area or not.
If AR information is readily available in the DirectShow structure, I'm not opposed to storing it. I think AviSource is out of luck, though. That means for the feature to be useful, the clip properties need to be set manually. Right now all clip properties are read-only.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.