Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
1st September 2013, 19:19 | #41 | Link | |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Quote:
Seems to require MaskTools (not Masktools2) - is that right? Which version? Tried MaskTools version 1.5.5 through 1.5.8 and get the same error with Avisynth version 2.60. EDIT - never mind, works OK with Masktools.dll in Plugins folder, ie not calling LoadPlugin. OK, 2nd problem: Changing the value of radius creates a number of errors, such as: "Resize: Source image too small for this resize method. Width=640, Support=2560" (radius=default, source=1280x720) "Resize: Planar destination width must be a multiple of 2." (radius=most values between 68 thru 98, source=1280x720) Last edited by raffriff42; 1st September 2013 at 22:34. |
|
2nd September 2013, 03:06 | #42 | Link | ||
Registered User
Join Date: Mar 2012
Posts: 29
|
RGBLevelsG
Quote:
Quote:
Sorry had to edit this a bit to make it cleaner. Code:
Function SoftBloom (clip last, int "radius", int "minlevels" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { radius = Default (radius, 2) edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect minlevels = Default (minlevels, 0) threshold = Default (threshold, 250) threshold = Round (Threshold * 219 / 255.0) + 16 min = Default (min, 254) max = Default (max, min +1) blur = Default (blur, 1) sat = Default (sat, 0.5) cont = Default (cont, 127) mul = Default (mul, 0.25) Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255) \ .Levels (minlevels, 0.1, threshold, 0, 255, false) \ .ConvertToYV12 () \ .GaussResize (width / edges, height / edges, p = blur) \ .BilinearResize (width, height) \ .Tweak (sat = sat) \ .Levels (0, 1.0, cont, 0, 255, false) White = BlankClip (Mask).Invert ("Y") MT_Merge (MT_lutxy (Mask \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true \ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul)) } Code:
Function SGlow (clip last, int "radius", int "minlevels" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { radius = Default (radius, 5) edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4) minlevels = Default (minlevels, 0) threshold = Default (threshold, 250) threshold = Round (Threshold * 219 / 255.0) + 16 min = Default (min, 254) max = Default (max, min +1) blur = Default (blur, 96) sat = Default (sat, 0.5) cont = Default (cont, 127) mul = Default (mul, 0.25) Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255) \ .Levels (minlevels, 0.1, threshold, 0, 255, false) \ .ConvertToYV12 () \ .AddBorders (edges, edges, edges, edges) \ .FastGaussBlur (blur) \ .Crop (edges, edges, edges * -1, edges * -1) \ .Tweak (sat = sat) \ .Levels (0, 1.0, cont, 0, 255, false) White = BlankClip (Mask).Invert ("Y") MT_Merge (MT_lutxy (Mask \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true \ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul)) } SoftBloom (radius = 128, min = 196,max=224, blur = 1 \ , minlevels = 0, threshold = 200, sat = 0.8, cont = 127, mul = 0.5) # smaller radius value wider blur, mul is bloom opacity, blur is set to 1, higher makes blur sharper (I keep it at 1 to prevent artifacts) or SGlow (radius = 12, min = 196,max=224, blur = 192 \ , minlevels = 0, threshold = 200, sat = 0.8, cont = 127, mul = 0.5) Lower width and height gives speedup of course, SimpleResize (720, 480) gets 30p on dual core pcs 1.6 ghz, faster cpus may get better results. Last edited by MJLives12; 2nd September 2013 at 03:30. Reason: quote indent, glow script addition |
||
2nd September 2013, 14:53 | #43 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Call SoftBloom & SGlow with random arguments!
A selection of cool-looking random SoftBloom settings (dropbox.com) Code:
## SoftBloom: fuzz test input args ## just keep frame stepping, see if anything breaks ;) ## (also a neat way to explore different effects) ## warning this video may cause seizures - do not play in real time return ScriptClip(C, "SoftBloom_Test(C)") ################################## ## SoftBloom: fuzz test input args # function SoftBloom_Test(clip C) { ## random inputs ## (limits are set based on guesswork; please adjust if needed) a_radius=Rand(C.Width/2) a_minlevels=Rand(512)-255 a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(255) a_mul=Rand(400)/100.0 stat="SoftBloom_B(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels) \ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold) \ + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) + ", mul=" + String(a_mul) \ + ")" return C.SoftBloom_B( \ radius=a_radius, minlevels=a_minlevels, \ min=a_min, max=a_max, threshold=a_threshold, \ sat=a_sat, cont=a_cont, mul=a_mul) \ .SubTitle(stat) } ################################## ## SoftBloom with constrained inputs and resizing ## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381 # Function SoftBloom_B (clip Last, int "radius", int "minlevels" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { ## (limits are set based on guesswork; please adjust if needed) radius = Min(Max(2, Default (radius, 2)), Width / 2) edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255) minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1) min = Min(Max(threshold+1, Default (min, 254)), 254) max = Min(Max(min+1, Default (max, min+1)), 255) blur = Min(Max(0, Default (blur, 1)), 100) sat = Min(Max(0.0, Default (sat, 0.5)), 4.0) cont = Min(Max(16, Default (cont, 127)), 255) mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0) old_wid = Width old_hgt = height new_wid = width / edges new_hgt = height / edges new_wid = Min(Max(64, new_wid), old_wid / 2) new_hgt = Min(Max(64, new_hgt), old_hgt / 2) new_wid = new_wid + new_wid % 2 new_hgt = new_hgt + new_hgt % 2 Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255) \ .Levels (minlevels, 0.1, threshold, 0, 255, false) \ .ConvertToYV12 () \ .GaussResize (new_wid, new_hgt, p = blur) \ .BilinearResize (old_wid, old_hgt) \ .Tweak (sat = sat) \ .Levels (0, 1.0, cont, 0, 255, false) White = BlankClip (Mask).Invert ("Y") MT_Merge (MT_lutxy (Mask \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true \ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul)) } Code:
## SGlow: fuzz test input args ## warning this video may cause seizures - do not play in real time return ScriptClip(C, "SGlow_Test(C)") ################################## ## SGlow: fuzz test input args ## note original SGlow seems to accept below random inputs OK # function SGlow_Test(clip C) { ## random inputs ## (limits are set based on guesswork; please adjust if needed) a_radius=Rand(C.Width/2) a_minlevels=Rand(512)-255 a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(255) a_mul=Rand(400)/100.0 a_blur=Rand(180) stat="SGlow(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels) \ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold) \ + ", blur=" + String(a_blur) + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) \ + ", mul=" + String(a_mul) \ + ")" return C.SGlow( \ radius=a_radius, minlevels=a_minlevels, \ min=a_min, max=a_max, threshold=a_threshold, \ blur=a_blur, sat=a_sat, cont=a_cont, mul=a_mul) \ .SubTitle(stat) } ################################## ## SGlow with constrained inputs ## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381 # Function SGlow_B (clip Last, int "radius", int "minlevels" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { ## (limits are set based on guesswork; please adjust if needed) radius = Min(Max(2, Default (radius, 5)), Width / 2) edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4) threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255) minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1) min = Min(Max(threshold+1, Default (min, 254)), 254) max = Min(Max(min+1, Default (max, min+1)), 255) blur = Min(Max(0, Default (blur, 96)), 180) sat = Min(Max(0.0, Float(Default (sat, 0.5))), 4.0) cont = Min(Max(16, Default (cont, 127)), 255) mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0) Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255) \ .Levels (minlevels, 0.1, threshold, 0, 255, false) \ .ConvertToYV12 () \ .AddBorders (edges, edges, edges, edges) \ .FastGaussBlur (blur) \ .Crop (edges, edges, edges * -1, edges * -1) \ .Tweak (sat = sat) \ .Levels (0, 1.0, cont, 0, 255, false) White = BlankClip (Mask).Invert ("Y") MT_Merge (MT_lutxy (Mask \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true \ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul)) } Last edited by raffriff42; 2nd September 2013 at 17:15. |
2nd September 2013, 21:11 | #45 | Link |
Registered User
Join Date: Mar 2012
Posts: 29
|
Merge Blur
Merge to gaussresize and FastGausBlur, it manages the blur strength, makes it lighter or less chunky. It works fine after I unticked "return ScriptClip(C, "SoftBloom_Test(C)")", I get an "I don't know what C means" error.
## SoftBloom: fuzz test input args ## just keep frame stepping, see if anything breaks ## (also a neat way to explore different effects) ## warning this video may cause seizures - do not play in real time #return ScriptClip(C, "SoftBloom_Test(C)") ################################## ## SoftBloom: fuzz test input args # function SoftBloom_Test(clip C) { ## random inputs ## (limits are set based on guesswork; please adjust if needed) a_radius=Rand(C.Width/2) a_minlevels=Rand(512)-255 a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(255) a_mul=Rand(400)/100.0 stat="SoftBloom_B(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels) \ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold) \ + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) + ", mul=" + String(a_mul) \ + ")" return C.SoftBloom_B( \ radius=a_radius, minlevels=a_minlevels, \ min=a_min, max=a_max, threshold=a_threshold, \ sat=a_sat, cont=a_cont, mul=a_mul) \ .SubTitle(stat) } ################################## ## SoftBloom with constrained inputs and resizing ## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381 # Function SoftBloom_B (clip Last, int "radius", int "minlevels" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { ## (limits are set based on guesswork; please adjust if needed) radius = Min(Max(2, Default (radius, 2)), Width / 2) edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255) minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1) min = Min(Max(threshold+1, Default (min, 254)), 254) max = Min(Max(min+1, Default (max, min+1)), 255) blur = Min(Max(0, Default (blur, 1)), 100) sat = Min(Max(0.0, Default (sat, 0.5)), 4.0) cont = Min(Max(16, Default (cont, 127)), 255) mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0) old_wid = Width old_hgt = height new_wid = width / edges new_hgt = height / edges new_wid = Min(Max(64, new_wid), old_wid / 2) new_hgt = Min(Max(64, new_hgt), old_hgt / 2) new_wid = new_wid + new_wid % 2 new_hgt = new_hgt + new_hgt % 2 Mask = Merge (Tweak (cont = 0, sat = 0) \ ,ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255) \ .Levels (minlevels, 0.1, threshold, 0, 255, false) \ .ConvertToYV12 () \ .GaussResize (new_wid, new_hgt, p = blur) \ .BilinearResize (old_wid, old_hgt) \ .Tweak (sat = sat) \ .Levels (0, 1.0, cont, 0, 255, false), mul) White = BlankClip (Mask).Invert ("Y") MT_Merge (MT_lutxy (Mask \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true \ , Mask) } SGlow ## SGlow: fuzz test input args ## warning this video may cause seizures - do not play in real time return ScriptClip(C, "SGlow_Test(C)") ################################## ## SGlow: fuzz test input args ## note original SGlow seems to accept below random inputs OK # function SGlow_Test(clip C) { ## random inputs ## (limits are set based on guesswork; please adjust if needed) a_radius=Rand(C.Width/2) a_minlevels=Rand(512)-255 a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(255) a_mul=Rand(400)/100.0 a_blur=Rand(180) stat="SGlow(rad=" + String(a_radius) + ", minlvl=" + String(a_minlevels) \ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", thrsh=" + String(a_threshold) \ + ", blur=" + String(a_blur) + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) \ + ", mul=" + String(a_mul) \ + ")" return C.SGlow_B( \ radius=a_radius, minlevels=a_minlevels, \ min=a_min, max=a_max, threshold=a_threshold, \ blur=a_blur, sat=a_sat, cont=a_cont, mul=a_mul) \ .SubTitle(stat) } ################################## ## SGlow with constrained inputs ## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381 # Function SGlow_B (clip Last, int "radius", int "minlevels" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { ## (limits are set based on guesswork; please adjust if needed) radius = Min(Max(2, Default (radius, 5)), Width / 2) edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4) threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255) minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1) min = Min(Max(threshold+1, Default (min, 254)), 254) max = Min(Max(min+1, Default (max, min+1)), 255) blur = Min(Max(0, Default (blur, 96)), 180) sat = Min(Max(0.0, Float(Default (sat, 0.5))), 4.0) cont = Min(Max(16, Default (cont, 127)), 255) mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0) Mask = Merge (Tweak (cont = 0, sat = 0) \ ,ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255) \ .Levels (minlevels, 0.1, threshold, 0, 255, false) \ .ConvertToYV12 () \ .AddBorders (edges, edges, edges, edges) \ .FastGaussBlur (blur) \ .Crop (edges, edges, edges * -1, edges * -1) \ .Tweak (sat = sat) \ .Levels (0, 1.0, cont, 0, 255, false), mul) White = BlankClip (Mask).Invert ("Y") MT_Merge (MT_lutxy (Mask \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true, Mask) } SoftBloom_Test () uv swapped (uncompressed image) SoftBloom_B(radius = 292, minlevels = 161, min = 149, max = 101 \ , threshold = 83, sat = 2.95, cont = 92, mul = 1.0) Last edited by MJLives12; 11th September 2013 at 13:32. Reason: SoftBloom_Test |
2nd September 2013, 23:33 | #46 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
>I get an "I don't know what C means" error.
Sorry, should have mentioned it - you need a line like: Code:
C=AviSource("some file.avi") Code:
C=Last Last edited by raffriff42; 3rd September 2013 at 00:32. |
3rd September 2013, 08:59 | #48 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Since the clip argument to ScriptClip becomes 'last' inside the run-time script, this is better written as:
Code:
return ScriptClip(C, "SoftBloom_Test()") |
3rd September 2013, 13:21 | #49 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Thanks Gavino!
Can I ask for your help, please? This is probably related. I'd like to generate my random arguments, call the function, and at the same time write the function call to to a log file - something like this: Code:
global g_logpath = "D:\path\logfile.txt" WriteFileStart("logfile.txt", """ "frameno" """, "Chr(9)", """ "args " """) WriteFileEnd(C, g_logpath, """ "#end" """) C = <something> return ScriptClip(C, "SoftBloom_Test()") function SoftBloom_Test(clip C) { ## random inputs a_radius=Rand(C.Width/2) a_minlevels=Rand(512)-255 a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(255) a_mul=Rand(400)/100.0 /* the following should be a valid Avisynth statement */ stat="SoftBloom_B(radius=" + String(a_radius) + ", minlevels=" + String(a_minlevels) \ + ", min=" + String(a_min) + ", max=" + String(a_max) + ", threshold=" + String(a_threshold) \ + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) + ", mul=" + String(a_mul) \ + ")" /* write frame number + tab char + statement to logfile...? */ return Eval(stat).ShowFrameNumber } Last edited by raffriff42; 3rd September 2013 at 13:32. |
3rd September 2013, 16:31 | #50 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
RaffRiff42,
This works but I dont really like the use of Global G_args (cant remember if there is an alternative way). Code:
C=Avisource("D:\avs\test.avi") global g_logpath = "D:\path\logfile.txt" C=WriteFileStart(C,g_logpath, """ "frameno" """, "Chr(9)", """ "args " """,append=false) C=WriteFileEnd(C, g_logpath, """ "#end" """) ## SoftBloom: fuzz test input args ## just keep frame stepping, see if anything breaks ;) ## (also a neat way to explore different effects) ## warning this video may cause seizures - do not play in real time return ScriptClip(C, "SoftBloom_Test()") ################################## ## SoftBloom: fuzz test input args # function SoftBloom_Test(clip C) { C ## random inputs a_radius=Rand(Width/2) a_minlevels=Rand(512)-255 a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(255) a_mul=Rand(400)/100.0 args="radius=" + String(a_radius,"%3.0f") + ", minlevels=" + String(a_minlevels,"% 4.0f") \ + ", min=" + String(a_min,"%3.0f") + ", max=" + String(a_max,"%3.0f") + ", threshold=" + String(a_threshold,"%3.0f") \ + ", sat=" + String(a_sat,"%3.3f") + ", cont=" + String(a_cont,"%3.0f") + ", mul=" + String(a_mul,"%3.3f") /* the following should be a valid Avisynth statement */ stat="SoftBloom_B(" + args + ")" RT_Debug("SoftBloom_B","["+string(current_frame)+"]",args,false) # RT_TxtWriteFile(String(current_frame)+Chr(9)+args,g_logpath,Append=true) /* write frame number + tab char + statement to logfile...? */ WriteFileStart(g_logpath,String(current_frame),"Chr(9)","args",append=True) return Eval(stat).ShowFrameNumber } ################################## ## SoftBloom with constrained inputs and resizing ## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381 # Function SoftBloom_B (clip Last, int "radius", int "minlevels" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { ## (limits are set based on guesswork; please adjust if needed) radius = Min(Max(2, Default (radius, 2)), Width / 2) edges = (width / radius) + ((width / radius) % 2) #bigger radius smaller effect threshold = Min(Max(16, Round (Default (threshold, 250) * 219 / 255.0) + 16), 255) minlevels = Min(Max(-255, Default (minlevels, 0)), threshold-1) min = Min(Max(threshold+1, Default (min, 254)), 254) max = Min(Max(min+1, Default (max, min+1)), 255) blur = Min(Max(0, Default (blur, 1)), 100) sat = Min(Max(0.0, Default (sat, 0.5)), 4.0) cont = Min(Max(16, Default (cont, 127)), 255) mul = Min(Max(0.0, Float(Default (mul, 0.25))), 4.0) old_wid = Width old_hgt = height new_wid = width / edges new_hgt = height / edges new_wid = Min(Max(64, new_wid), old_wid / 2) new_hgt = Min(Max(64, new_hgt), old_hgt / 2) new_wid = new_wid + new_wid % 2 new_hgt = new_hgt + new_hgt % 2 Mask = ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255) \ .Levels (minlevels, 0.1, threshold, 0, 255, false) \ .ConvertToYV12 () \ .GaussResize (new_wid, new_hgt, p = blur) \ .BilinearResize (old_wid, old_hgt) \ .Tweak (sat = sat) \ .Levels (0, 1.0, cont, 0, 255, false) White = BlankClip (Mask).Invert ("Y") MT_Merge (MT_lutxy (Mask \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", U = 3, V = 3), White, luma = true \ ,Merge (Tweak (cont = 0, sat = 0), Mask, mul)) } function RGBlevelsG(clip clp, \ int "input_low", float "gamma", int "input_high", \ int "output_low", int "output_high", bool "show_function") { input_low = Default(input_low, 0) gamma = Default(gamma, 1.0) input_high = Default(input_high, 255) output_low = Default(output_low, 0) output_high = Default(output_high, 255) show_function = Default(show_function, false) wicked = gamma > 1.0 \ ? "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+ \ " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + x * x 255 x - * + 255 /" \ : "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+ \ " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + 255 x - * x x * + 255 /" return( show_function ? clp.subtitle(wicked) : clp.rgblut(rexpr = wicked, gexpr = wicked,bexpr = wicked, R = 3, G = 3, B = 3) ) } Code:
frameno args 0 radius= 41, minlevels=-220, min=238, max=235, threshold= 44, sat=1.240, cont= 3, mul=1.580 0 radius= 41, minlevels=-220, min=238, max=235, threshold= 44, sat=1.240, cont= 3, mul=1.580 1 radius=262, minlevels= 145, min=117, max= 95, threshold= 76, sat=0.270, cont= 16, mul=0.910 1 radius=262, minlevels= 145, min=117, max= 95, threshold= 76, sat=0.270, cont= 16, mul=0.910 2 radius=147, minlevels= -89, min= 1, max= 81, threshold= 6, sat=2.040, cont= 77, mul=1.530 3 radius=292, minlevels=-161, min=149, max=101, threshold= 83, sat=2.950, cont= 92, mul=1.260 4 radius=175, minlevels= 19, min= 91, max= 22, threshold=167, sat=2.990, cont=205, mul=2.940 5 radius=223, minlevels= 4, min= 80, max=243, threshold= 78, sat=2.640, cont= 96, mul=1.110 6 radius=129, minlevels= -43, min=147, max=104, threshold= 22, sat=3.570, cont=147, mul=0.590 7 radius=179, minlevels=-242, min= 97, max= 13, threshold= 76, sat=2.350, cont= 5, mul=2.420 8 radius=288, minlevels= 155, min=150, max= 17, threshold=139, sat=2.480, cont=161, mul=2.050 9 radius=226, minlevels=-182, min=240, max= 50, threshold=216, sat=3.010, cont=168, mul=3.480 #end EDIT: But RT_Debug output is correct (if uncomment). (Something in other funcs is pulling in frames 0,1 twice each) Debug Code:
00000005 1.84072244 SoftBloom_B [0] radius= 41, minlevels=-220, min=238, max=235, threshold= 44, sat=1.240, cont= 3, mul=1.580 00000006 2.02774215 SoftBloom_B [1] radius=262, minlevels= 145, min=117, max= 95, threshold= 76, sat=0.270, cont= 16, mul=0.910 00000007 2.18231225 SoftBloom_B [2] radius=147, minlevels= -89, min= 1, max= 81, threshold= 6, sat=2.040, cont= 77, mul=1.530 00000008 2.33077383 SoftBloom_B [3] radius=292, minlevels=-161, min=149, max=101, threshold= 83, sat=2.950, cont= 92, mul=1.260 00000009 2.47816133 SoftBloom_B [4] radius=175, minlevels= 19, min= 91, max= 22, threshold=167, sat=2.990, cont=205, mul=2.940 00000010 2.62778354 SoftBloom_B [5] radius=223, minlevels= 4, min= 80, max=243, threshold= 78, sat=2.640, cont= 96, mul=1.110 00000011 2.77748704 SoftBloom_B [6] radius=129, minlevels= -43, min=147, max=104, threshold= 22, sat=3.570, cont=147, mul=0.590 00000012 2.92913008 SoftBloom_B [7] radius=179, minlevels=-242, min= 97, max= 13, threshold= 76, sat=2.350, cont= 5, mul=2.420 00000013 3.07594872 SoftBloom_B [8] radius=288, minlevels= 155, min=150, max= 17, threshold=139, sat=2.480, cont=161, mul=2.050 00000014 3.22120976 SoftBloom_B [9] radius=226, minlevels=-182, min=240, max= 50, threshold=216, sat=3.010, cont=168, mul=3.480 Code:
################################## ## SoftBloom: fuzz test input args # function SoftBloom_Test(clip C) { C ## random inputs a_radius=Rand(Width/2) a_minlevels=Rand(512)-255 a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(255) a_mul=Rand(400)/100.0 args="radius=" + String(a_radius,"%3.0f") + ", minlevels=" + String(a_minlevels,"% 4.0f") \ + ", min=" + String(a_min,"%3.0f") + ", max=" + String(a_max,"%3.0f") + ", threshold=" + String(a_threshold,"%3.0f") \ + ", sat=" + String(a_sat,"%3.3f") + ", cont=" + String(a_cont,"%3.0f") + ", mul=" + String(a_mul,"%3.3f") /* the following should be a valid Avisynth statement */ stat="SoftBloom_B(" + args + ")" RT_Debug("SoftBloom_B","["+string(current_frame)+"]",args,false) RT_TxtWriteFile(String(current_frame)+Chr(9)+args,g_logpath,Append=true) /* write frame number + tab char + statement to logfile...? */ # WriteFileStart(g_logpath,String(current_frame),"Chr(9)","args",append=True) return Eval(stat).ShowFrameNumber } EDIT: Fixed Again
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 3rd September 2013 at 19:44. Reason: Added Logfile |
3rd September 2013, 17:21 | #51 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
Works great StainlessS! Thank you! Nicely formatted too, which helps if you want compare calls to see what's changed. Still scratching my head over what I done wrong...
This thing is super useful because of the wide variety of possible bloom/fog/whiteout/neon effects, and what looks great for one source looks so-so on another. (EDIT so-so? How about frikin' unwatchable?) Stepping through the script, you can find an effect you like within seconds, then look up the frame number in the logfile and paste the args into a call to C.SoftBloom_B(...) (One thing: the float args should be formatted as something like String(X,"%5.2f"), not String(X,"%3.0f"), which turns them into ints) EDIT didn't see the note about 0 and 1 showing twice...but it doesn't matter for our purposes. Since the log is being written as frames are served, there's no guarantee of monotonicity or other big words like that there. If I wanted one-and-only-one line per frame, in ascending order, I would use the Sort function in TextPad, or another similar text editor - if one exists Last edited by raffriff42; 3rd September 2013 at 19:01. |
3rd September 2013, 17:34 | #52 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Ooooops, fixed floats.
The amended script at end using RT_TxtWriteFile() fixes the double frame 0,1 output, can change G_args to local. EDIT: Quote:
single Beep command that sounded like a complete tune that was written by a human, but very badly off-key (was very funny, lasting several minutes) {Brits ONLY:- Reminds me of Les Dawson playing piano. Non Brits, Google "Les Dawson Piano"}
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 3rd September 2013 at 21:17. |
|
3rd September 2013, 19:12 | #53 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Code:
/* write frame number + tab char + statement to logfile. */ # G_Args can now be local C.WriteFileStart(g_logpath,"current_frame","Chr(9)","G_Args") |
|
3rd September 2013, 19:26 | #54 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Thank you Gavino, also needed 'append=true'. Post #50 fixed. (I've used exact same solution before, but forgot)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
3rd September 2013, 19:37 | #55 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Fixed again as here: Code:
WriteFileStart(g_logpath,String(current_frame),"Chr(9)","args",append=True)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 3rd September 2013 at 19:46. |
|
3rd September 2013, 21:54 | #56 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Nice workaround, Mr S. Perhaps instead I should just have suggested: Code:
C.GWriteFile(g_logpath,"current_frame","Chr(9)","args", args="args") |
|
17th September 2013, 23:51 | #57 | Link |
Registered User
Join Date: Mar 2012
Posts: 29
|
FastGauss with levels
Added Levels to fastgauss from Didée function to brighten blur in SoftGlow.
Code:
function FastGauss(clip clp, float rx, float ry) { ox=clp.width() oy=clp.height() clp.Levels (0, 0.1, 127, 0, 255, false).bicubicresize(m4(ox/rx),m4(oy/ry)).bicubicresize(ox,oy,1,0) } function m4(float x) {x<16?16:int(round(x/4.0)*4)} Code:
################################## ## SoftGlow with constrained inputs and resizing ## original @ http://forum.doom9.org/showthread.php?p=1642381#post1642381 # Function SoftGlow (clip c, int "radius" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { c ## (limits are set based on guesswork; please adjust if needed) radius = Min(Max(2, Default (radius, 2)), Width / 2) edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4) threshold = Min(Max(16, Round (Default (threshold, 200) * 219 / 255.0) + 16), 255) min = Min(Max(threshold+1, Default (min, 254)), 254) max = Min(Max(min+1, Default (max, min+1)), 255) blur = Min(Max(0, Default (blur, 24)), 768) sat = Min(Max(0.0, Default (sat, 1.0)), 4.0) cont = Min(Max(1, Default (cont, 0)), 256) mul = Min(Max(0.0, Float(Default (mul, 1.0))), 1.0) rmax_set=255.0 rwmax=last.width/blur rhmax=last.height/blur rmax= (rwmax <= rhmax) ? rwmax : rhmax radius=(((rmax-1)*(radius-1))/(rmax_set-1))+1 b=radius-1 b=b*b*b b=b*192/rmax/rmax/rmax width=Round(last.width/blur) height=Round(last.height/blur) Mask = Merge (last \ ,MT_lutxy (last \ ,ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255).ConvertToYV12 () \ .Tweak (sat = sat) \ .AddBorders (edges, edges, edges, edges) \ .FastGauss (blur, blur) \ .Crop (edges, edges, edges * -1, edges * -1) \ .Levels (0, 1.0, threshold, 0, 255, false) \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", Y = 4, U = 3, V = 3), mul) White = MT_lutxy (BlankClip (Mask, color_yuv = $FF8080) \ ,Mask.ColorYUV (cont_u = cont, cont_v = cont) \ ,yexpr = "256 0 x - 256 y - * 256 / -", Y = 3, U = 4, V = 4) MT_Merge (White, Mask, chroma = "process") } Code:
## SoftGlow: fuzz test input args ## just keep frame stepping, see if anything breaks ## (also a neat way to explore different effects) ## warning this video may cause seizures - do not play in real time ################################## ## SoftGlow: fuzz test input args # function SoftGlow_Test(clip C) { C ## random inputs a_radius=Rand(Width/2) a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(400) a_mul=Rand(100)/100.0 a_blur=Rand(180) args="radius=" + String(a_radius,"%3.0f") \ + ", min=" + String(a_min,"%3.0f") + ", max=" + String(a_max,"%3.0f") + ", threshold=" + String(a_threshold,"%3.0f") \ + ", blur=" + String(a_blur) + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) /* the following should be a valid Avisynth statement */ stat="SoftGlow(" + args + ")" RT_Debug("SoftGlow","["+string(current_frame)+"]",args,false) # RT_TxtWriteFile(String(current_frame)+Chr(9)+args,g_logpath,Append=true) /* write frame number + tab char + statement to logfile...? */ WriteFileStart(g_logpath,String(current_frame),"Chr(9)","args",append=True) return Eval(stat).ShowFrameNumber } Code:
C = last global g_logpath = "C:\<dir>\logfile.txt" C=C.WriteFileStart(g_logpath, """ "frameno" """, "Chr(9)", """ "args " """,append=false) C=C.WriteFileEnd(g_logpath, """ "#end" """) ScriptClip(c, "SoftGlow_Test(c)") Also FastCross (Plus effect version of Didée FastGauss Code:
function FastCross(clip clp, float rx, float ry) { ox=clp.width() oy=clp.height() Merge (clp.Levels (0, 0.1, 127, 0, 255, false).bilinearresize(m4(ox/rx),m4(oy)).bicubicresize(ox,oy,1,0) \ ,clp.Levels (0, 0.1, 127, 0, 255, false).bilinearresize(m4(ox),m4(ry/ry)).bicubicresize(ox,oy,0,1),0.5) } function m4(float x) {x<16?16:int(round(x/4.0)*4)} Code:
Function PGlow (clip c, int "radius" \ , int "min", int "max", int "threshold", int "blur", float "sat", int "cont", float "mul") { c ## (limits are set based on guesswork; please adjust if needed) radius = Min(Max(2, Default (radius, 2)), Width / 2) edges = (radius % 4) == 0 ? radius : radius + 4 - (radius % 4) threshold = Min(Max(16, Round (Default (threshold, 200) * 219 / 255.0) + 16), 255) min = Min(Max(threshold+1, Default (min, 254)), 254) max = Min(Max(min+1, Default (max, min+1)), 255) blur = Min(Max(0, Default (blur, 24)), 768) sat = Min(Max(0.0, Default (sat, 1.0)), 4.0) cont = Min(Max(1, Default (cont, 0)), 256) mul = Min(Max(0.0, Float(Default (mul, 1.0))), 1.0) rmax_set=255.0 rwmax=last.width/blur rhmax=last.height/blur rmax= (rwmax <= rhmax) ? rwmax : rhmax radius=(((rmax-1)*(radius-1))/(rmax_set-1))+1 b=radius-1 b=b*b*b b=b*192/rmax/rmax/rmax width=Round(last.width/blur) height=Round(last.height/blur) Mask = Merge (last \ ,MT_lutxy (last \ ,ConvertToRGB32 ().RGBLevelsG (min, 1.0, max, 0, 255).ConvertToYV12 () \ .Tweak (sat = sat) \ .AddBorders (edges, edges, edges, edges) \ .FastCross (blur, blur) \ .Crop (edges, edges, edges * -1, edges * -1) \ .Levels (0, 1.0, threshold, 0, 255, false) \ ,uexpr = " y 128 < x y * 128 /" \ ,vexpr = " y 128 < x y * 128 /", Y = 4, U = 3, V = 3), mul) White = MT_lutxy (BlankClip (Mask, color_yuv = $FF8080) \ ,Mask.ColorYUV (cont_u = cont, cont_v = cont) \ ,yexpr = "256 0 x - 256 y - * 256 / -", Y = 3, U = 4, V = 4) MT_Merge (White, Mask, chroma = "process") } Code:
## PGlow: fuzz test input args ## just keep frame stepping, see if anything breaks ## (also a neat way to explore different effects) ## warning this video may cause seizures - do not play in real time ################################## ## PGlow: fuzz test input args # function PGlow_Test(clip C) { C ## random inputs a_radius=Rand(Width/2) a_min=Rand(254) a_max=Rand(255) a_threshold=Rand(255) a_sat=Rand(400)/100.0 a_cont=Rand(400) a_mul=Rand(100)/100.0 a_blur=Rand(180) args="radius=" + String(a_radius,"%3.0f") \ + ", min=" + String(a_min,"%3.0f") + ", max=" + String(a_max,"%3.0f") + ", threshold=" + String(a_threshold,"%3.0f") \ + ", blur=" + String(a_blur) + ", sat=" + String(a_sat) + ", cont=" + String(a_cont) /* the following should be a valid Avisynth statement */ stat="PGlow(" + args + ")" # RT_Debug("SoftGlow","["+string(current_frame)+"]",args,false) # RT_TxtWriteFile(String(current_frame)+Chr(9)+args,g_logpath,Append=true) /* write frame number + tab char + statement to logfile...? */ WriteFileStart(g_logpath,String(current_frame),"Chr(9)","args",append=True) return Eval(stat).ShowFrameNumber } Code:
C = last global g_logpath = "C:\Fraps\movies\logfile.txt" C=C.WriteFileStart(g_logpath, """ "frameno" """, "Chr(9)", """ "args " """,append=false) C=C.WriteFileEnd(g_logpath, """ "#end" """) ScriptClip(c, "PGlow_Test(c)") Code:
PGlow (radius=2,min=200,max=235,sat=1.0,mul=0.5,cont=512,blur=24,threshold=127) Last edited by MJLives12; 18th September 2013 at 00:40. Reason: SoftGlow_test error fix, added blur to SoftGlow_Test, added PGlow function, logfile |
18th September 2013, 01:13 | #58 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
@MjLives12,
No real need for RT_Debug() in "Optional SoftGlow Test" (maybe), perhaps at least comment out. Nearly mentioned before but did not bother. # unless debugging, handy for you, but not necessary to the script. Peace bro. (unless using RT_ elsewhere, dont think you do).
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 18th September 2013 at 01:16. |
18th September 2013, 02:48 | #59 | Link | |
Registered User
Join Date: Mar 2012
Posts: 29
|
RT_Debug and RT_TxtWriteFile
Quote:
function, I get an error saying "there's no function named RT_Debug", also RT_TxtWriteFile when selected. I don't really use debugging (should've unchecked, but would worked for others who have the function)...I really use manual scripting but script is still useful. I'm such a noob. Peace. |
|
18th September 2013, 15:39 | #60 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
RT_debug and RT_TxtWriteFile are functions from RT_Stats dll, runtime/compile time functions.
RT_Debug takes 1 or more strings, and outputs to debugview window so you can see debugging information in real time. DebugView from SysInternals, bought out by Microsoft, here: http://technet.microsoft.com/en-gb/s.../bb896647.aspx Debugview is highly recommended if you develop scripts especially if you use either Scriptclip or GScript, you can see some example RT_Debug output in post #50, 3rd code block, and the RT_Debug line in 1st code block of same post. You can remove both RT_ funcs, as they are not now needed in your script.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
Thread Tools | Search this Thread |
Display Modes | |
|
|