View Full Version : How to create a new clip with a new Y, U and V ?
fjhdavid
10th May 2009, 18:35
Dear all,
I have a clip C (Y,U,V)
I want to create, under avisynth, a new clip D (Y',U',V')
where, for example (I have to tweak the coefficient):
Y'=Y+2*U+3*V
U'=2*Y+3*U+4*V
V'=Y-U-V
thanks for your help
Francois
PS: In fact, I had a problem with my DVD recorder (I recorded with an RVB wire) and there is an error in the matrix which computed Y,U and V from R,G and B. So I want to fix the problem this way (which is the only way, I think).
Manao
10th May 2009, 19:45
With the masktools :
video = source(...).converttoyv12
w = video.width
h = video.height
y = video
u = video.utoy.lanczosresize(w,h)
v = video.vtoy.lanczosresize(w,h)
yp = mt_lutxyz(y, u, v, "x 1 * y 2 * z 3 * + +")
up = mt_lutxyz(y, u, v, "x 2 * y 3 * z 4 * + +").lanczosresize(w/2,h/2)
vp = mt_lutxyz(y, u, v, "x 1 * y -1 * z -1 * + +").lanczosresize(w/2,h/2)
return ytouv(up,vp,yp)The loading of the script will be slow.
fjhdavid
10th May 2009, 19:53
thank you I will test it
fjhdavid
11th May 2009, 17:32
Manao,
Under dvdrb pro, everything is 4x times longer (4x number of frames) and bigger (final clip is 4x bigger)?
I post the problem on the dvd-rb pro forum, but maybe you know the answer?
Thanks
Manao
11th May 2009, 17:37
It shouldn't happen. What do you get with virtual dub ?
fjhdavid
11th May 2009, 18:52
I don't use virtual dub.
In fact during encoding, I have 3200 frames for a segment where I had only 800 with other avisynth filters.
Then during rebuilding, I have the first 800 frames which are rebuilt very fast and then I have "corrupted frames from 801 to 3200".
At the end the final clip has the normal duration and play very well but is 4x bigger. (it is normal as dvd-rb see 4x frames).
Manao
11th May 2009, 19:04
It didn't ask if you were using virtual dub, I asked you to try with virtual dub. It's a program I trust, while I have no idea what dvd-rb is (and consequently don't trust it)
fjhdavid
12th May 2009, 00:03
Manao,
Before trying to learn virtual dub, I just removed the "return" statement from the script and it works perfectly.
I don't know why? but maybe you know?
Francois
Gavino
12th May 2009, 00:25
I just removed the "return" statement from the script and it works perfectly.
As far as Avisynth is concerned, that should make absolutely no difference at all.
It must be a feature of dvd-rb - I'm just guessing, but perhaps it adds things to the end of your script and putting in 'return' messes that up.
fjhdavid
12th May 2009, 09:38
yes, you are right, DVD-RB adds a converttoYV12 at the end of each script with a "trim" statement before.
Francois
Gavino
12th May 2009, 10:07
DVD-RB adds a converttoYV12 at the end of each script with a "trim" statement after.
That's the wrong way to do it - it should use Import to include your script inside an outer one of its own, then 'return' would not affect the outer part.
fjhdavid
4th June 2009, 00:09
Manao,
When I use the mt_lutxyz from masktools, does the output values in the "expr" are calculated as doubles, rounded to ints and then clamped/clipped to unsigned chars?
ex: if x= 200, y=0 and z=0 and if I apply the following script:
mt_lutxyz(y, u, v, "x 1.60 * y * z * + +")
colorYUV(off_y=-100)
I will have an intermediate output of 320 (200*1.6) which is bigger than 255 and then if I substract 100 does the result will be 220 (200*1.6-100) or 155 (200*1.6 rounded to 255 and 255-100)
thanks
Francois
Manao
4th June 2009, 05:22
The rounding and clipping will be done at the end of the expression. So you'll get 220.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.