View Full Version : Smooth colour transition.
coolgit
19th January 2022, 21:30
I have a video with green tint after a scene change and i used (vdub avisynth)
ShiftCCT(9200).SmoothLevels(0, 1.3, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100).SmoothTweak(brightness=0, contrast=1, saturation=1, hue1=10, hue2=0, Lmode=0, limiter=false)
to change to a nice colour. However at the end i want to go back to pre green tint. I was expecting a scene change at the end but unfortunately there isn't. It just transit slowing to the next scene (not blend).
Normally i would use vdub curve editor to make any transition, say over 100 frames. How can i do this with avisynth to transit back to
ShiftCCT(9200).SmoothLevels(0, 1.3, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100).SmoothTweak(brightness=0, contrast=1, saturation=1, hue1=0, hue2=0, Lmode=0, limiter=false)
or
ShiftCCT(9200).SmoothLevels(0, 1.3, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100)
cheers
poisondeathray
19th January 2022, 23:22
One way is to use Animate()
http://avisynth.nl/index.php/Animate
You have to include the entries for all the parameters of the function (even if they are default), from left to right, until you reach the final one that changes values. hue1 is the 5th argument. The ones to the right (6th, 7th, 8th....) can be excluded if they are default
SmoothTweak(clip, brightness=0, contrast=1, saturation=1, hue1=0,hue2=0,limiter=false,tvrange=false,lmode=0,limitstr=100, interp=100,dither=75,hq=false,usemt=0,useopt=0,debug=false,screenw=-1,screenh=-1,scale=true)
eg.
base clip is colorbars
apply smoothtweak from frame 50 to 150 , changing the value of hue1 at 10, to hue1 at 0
a=colorbars(pixel_type="yv12").trim(0,199)
Animate(50,150, "SmoothTweak", a,0,1,1,10, a, 0,1,1,0)
wonkey_monkey
19th January 2022, 23:38
I would use Dissolve()
http://avisynth.nl/index.php/Dissolve
If the fade starts at frame 87 and ends at frame 121:
clip = ... # source clip
normal = clip.ShiftCCT(9200).SmoothLevels(0, 1.3, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100) # untouched colour
tweaked = normal.SmoothTweak(brightness=0, contrast=1, saturation=1, hue1=10, hue2=0, Lmode=0, limiter=false) # green tint removed
tweaked = tweaked.trim(0,121) # from start of clip to end of fade
normal = normal.trim(87,0) # from start of fade to end of clip
output = dissolve(tweaked, normal, 35) # 35 = 121-87+1
It's a lot less work than fiddling around with Animate() with all its pitfalls (such as having to specify parameters in order). FYI, if you want a smooth interpolation on a floating point argument with Animate(), you must specify it as a floating point number. So:
Animate(50,150, "SmoothTweak", a,0,1,1,10, a,0,1,1,0 ) # this won't work as expected (edit: actually it will in this case)
Animate(50,150, "SmoothTweak", a,0,1,1,10.0, a,0,1,1,0.0) # this will (edit: actually it won't, see below)
Also some of those examples on the Animate() page are borked.
poisondeathray
20th January 2022, 00:00
It's a lot less work than fiddling around with Animate() with all its pitfalls (such as having to specify parameters in order). FYI, if you want a smooth interpolation on a floating point argument with Animate(), you must specify it as a floating point number. So:
Animate(50,150, "SmoothTweak", a,0,1,1,10, a,0,1,1,0 ) # this won't work as expected
Animate(50,150, "SmoothTweak", a,0,1,1,10.0, a,0,1,1,0.0) # this will
Also some of those examples on the Animate() are borked.
Yes, Animate is very finicky
The example worked without specifying float in avs+ r3593 .
Changing to
Animate(50,150, "SmoothTweak", a,0,1,1,10.0, a, 0,1,1,0.0)
"Invalid arguments to function 'Animate'"
The version I have, smoothadjust v3.2, hue1 does not take decimals
a=colorbars(pixel_type="yv12").trim(0,199)
a.smoothtweak(hue1=3.2)
"the named argument "hue1" to smoothtweak had the wrong type
But saturation definitely does (e.g. smoothtweak(saturation=2.3) ) , and animate() works ok without specifying the decimal
wonkey_monkey
20th January 2022, 00:28
Oh that's odd, I tried Animate() with FastBlur() and it only animated smoothly with floating point arguments.
Ah, I see, hue1 and hue2 are acually specifically integer parameters. Seems like a slight deficiency of SmoothTweak.
coolgit
20th January 2022, 11:08
Ok got it done. Tried Animate and after 2 hours gave up. For some reason it doesn't fade at all.
v9=Animate(a,62036,62236, "SmoothTweak", 0,1,0.5,8, 0,1,1,0).Animate(62036,62236, "SmoothLevels", 0,1.1,255,0,255,100,0,true,"default",3, 0,1,255,0,255,100,0,true,"default",0).Animate(62036,62236, "ShiftCCT", 7700, 6675)
Tried Dissolve and in 5 minutes i got it to work.
a=ShiftCCT(fb,7700).SmoothLevels(0, 1.1, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100)
b=a.SmoothTweak(brightness=0, contrast=1.1, saturation=0.7, hue1=10, hue2=0, Lmode=0, limiter=false)
b=b.Trim(58051,62236)
a=a.Trim(62036,0)
v9=dissolve(b,a,201)
Sods law dictates one should respond to the 1st reply before moving on. I wish i did the 2nd reply then try the 1st one and after 5 minutes if it doesn't work then stop, could have saved 1 hour 55 minutes of my life :D:D:D:D
Thanks for the help.
Any chance either of you understand staxrip?
https://forum.doom9.org/showthread.php?p=1961631#post1961631
coolgit
21st January 2022, 05:38
Is this correct for fade at start of clip? Also are the # notes correct?
src=filename
fb=ContinuityFixer(src, left=1, top=0, right=1, bottom=0, radius=0)
a=fb
b=a.ShiftCCT(6700).SmoothLevels(0, 1.1, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100).SmoothTweak(brightness=0, contrast=1, saturation=0.7, hue1=10, hue2=0, Lmode=0, limiter=false)
b=b.Trim(0,100) # assume Trim(0,100) from start of clip to end of clip (0,100)
a=a.Trim(0,50) # from start of fade to end of clip (50,0) OR from start of clip to end of fade (0,50)
v=dissolve(a,b,51) # 51 = 100(b.end of clip) -50(a.start of fade) +1 (b,a) OR 50(a.end of fade) - 0(b.start of clip) + 1 (a,b)
Return v
StainlessS
21st January 2022, 11:30
Dissolve(clip clip1, clip clip2 [,...], int overlap [, float fps])
Dissolve is like AlignedSplice, except that the clips are combined with some overlap. The last overlap frames of the first video stream are blended progressively with the first overlap frames of the second video stream so that the streams fade into each other. The audio streams are blended similarly.
The final 51 frames of a are overlaid with the first 51 frames of b,
http://avisynth.nl/index.php/Dissolve
coolgit
21st January 2022, 16:23
The final 51 frames of a are overlaid with the first 51 frames of b,
http://avisynth.nl/index.php/Dissolve
I am not sure what your point is.
StainlessS
21st January 2022, 20:40
Forget my post,
I have no idea what your post code block is saying/asking.
coolgit
21st January 2022, 23:44
Expanded to include fade at the start and the end of clip. Worked and hoping it is the right way.
src=FFmpegSource2(filename)
fb=ContinuityFixer(src, left=1, top=0, right=1, bottom=0, radius=0)
v1=Trim(src,0,164712)
a=fb
a2=fb.SmoothLevels(0, 1.2, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100)
b=a.ShiftCCT(6700).SmoothLevels(0, 1.1, 255, 0, 255, Lmode=3, darkSTR=100, brightSTR=100).SmoothTweak(brightness=0, contrast=1, saturation=0.7, hue1=10, hue2=0, Lmode=0, limiter=false)
b=b.Trim(164713,168097) # assume Trim(0,100) from start of clip to end of clip (0,100)
a=a.Trim(164713,164813) # from start of fade to end of clip (50,0) OR from start of clip to end of fade (0,50)
a2=a2.Trim(167997,168097)
v=dissolve(a,b,a2,101) # 51 = 100(b.end of clip) -50(a.start of fade) +1 (b,a) OR 50(a.end of fade) - 0(b.start of clip) + 1 (a,b)
d=Despot(v,mthres=16,p1=20,p2=10,pwidth=2,pheight=2,sign=-2,maxpts=10,show=0)
AlignedSplice(v1,d)
#StackHorizontal(src,last)
Return last
There was a problem when i wanted to compare source with new clip using StackHorizontal. The src side was frame 0 and the last side was frame 164713.
Tried looking at StackHorizontal and FFmpegSource2 for a way to instruct avisynth to start src side at 164713 but couldn't find anything.
ie. FFmpegSource2(start frame=164713 blah blah) or StackHorizontal(src(start frame=164713),last)
I had to add v1=Trim(src,0,164712) and AlignedSplice(v1,d) to make it work.
Is there a 'proper', 'cool', filter that gets the job done?
On the side note, my first attempt was weird. I was using vdub 6-axis colour correction filter for final fine tuning.
Then i realised i need to use curve editor to fade the filter alongside Dissolve filter and it worked like a charm on the 2nd attempt.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.