Log in

View Full Version : how to draw a line on the wiping edge for before after compare?


edison
25th June 2021, 14:41
I am trying to make a before after video by avisynth scripit.

I have finished the before_after code, but i hope add a Line on the edge of wiping (like here :https://imgsli.com/NTg3NDQ/0/4).

my code:

LoadPlugIn("C:\Program Files (x86)\AviSynth+\plugins64+\TxPlus.dll")


frame_start= 0
frame_end = 599

after=ImageSource ("\\192.168.2.186\e\article\hades_canyon\fsr\4k\4k_fsr_off.png", frame_start , frame_end, 60)
before=ImageSource ("\\192.168.2.186\e\article\hades_canyon\fsr\4k\4k_fsr_ultra_quality.png", frame_start, frame_end, 60)

scale_factor = 2
img_width = after.Width()
img_height = before.Height()

offset_crop_v = 512
offset_crop_h = -1

after_zoomin=PointResize(after, img_width*scale_factor, img_height*scale_factor)
before_zoomin=PointResize(before, img_width*scale_factor, img_height*scale_factor)

after_zoomin_crop = Crop(after_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)
before_zoomin_crop = Crop(before_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)

subtitle_before = Subtitle(before_zoomin_crop, "FSR Ultra Quality", font = "Arial", size = 48.0, text_color=color_white, align = 3)
subtitle_after = Subtitle(after_zoomin_crop, "FSR OFF", font = "Arial", size = 48.0, text_color=color_white, align = 1)

#http://www.avisynth.nl/users/vcmohan/TxPlus/docs/Wipe.html
Wipe(subtitle_before, subtitle_after, 10, 3)

how can I do that?

StainlessS
25th June 2021, 15:03
I have never used TxPlus Wipe(), but suspect that only real way of having your required result
would be if Wipe() had that built-in functionality, or if you totally implemented wipe yourself in script.

Perhaps a feature request in TxPlus thread would be advisable.

EDIT: Vampirdom's SoftWipe():- https://forum.doom9.org/showthread.php?t=163395&highlight=wipe
Maybe starting point for hacking your script version wipe.

EDIT: Or Stickboy's Wipe:- https://forum.doom9.org/showthread.php?p=352535#post352535

edison
25th June 2021, 15:50
Thanks for your reply.
I think there is easy way to do it: insert a white background video to wipe the "before" video.

StainlessS
25th June 2021, 17:21
You would ideally provide script that will work without your specific frames, eg using colorbars, so that others may assist.

Something like below maybe.


LoadPlugIn(".\x86\TxPlus.dll")

frame_start= 0
frame_end = 599
FPS=60

after=Colorbars.Killaudio.Trim(frame_start,frame_End).BilinearResize(1920,1200).AssumeFPS(FPS)
before=after.FlipHorizontal

scale_factor = 2
img_width = after.Width()
img_height = before.Height()

offset_crop_v = 512
offset_crop_h = -1

after_zoomin = PointResize(after, img_width*scale_factor, img_height*scale_factor)
before_zoomin = PointResize(before, img_width*scale_factor, img_height*scale_factor)

after_zoomin_crop = Crop(after_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)
before_zoomin_crop = Crop(before_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)

subtitle_before = Subtitle(before_zoomin_crop, "FSR Ultra Quality", font = "Arial", size = 48.0, text_color=color_white, align = 3)
subtitle_after = Subtitle(after_zoomin_crop, "FSR OFF", font = "Arial", size = 48.0, text_color=color_white, align = 1)

Wipe(subtitle_before, subtitle_after, 10, 3)


You might want to change colorbars BilinearResize() size, and specify what you expect at sequence start and end.

vcmohan
26th June 2021, 13:51
One can use wipe of TxPlus. The first video A will be with before frames and second B with after frames.

StainlessS
26th June 2021, 14:09
One can use wipe of TxPlus.
He is using TxPlus, he wants a vertical bar between both sides of the Wipe.

vcmohan
27th June 2021, 13:44
A feature such as this can be introduced. But will the line not distract?
Yes if a feature request is posted on TxPlus thread I will look into it.

wonkey_monkey
27th June 2021, 14:12
For two planar RGB clips:

expr(a,b, "sx width time * X@ >= sx X 1 + < & 255 sx X < x y ? ?")

For two YUV clips:

expr(a,b, "sx width time * X@ >= sx X 1 + < & 255 sx X < x y ? ?", "sx width time * X@ >= sx X 1 + < & 128 sx X < x y ? ?", "sx width time * X@ >= sx X 1 + < & 128 sx X < x y ? ?")

These will wipe over the whole duration so use trims to localise it.

StainlessS
27th June 2021, 15:49
Wow! Wonkey, you're like a cross between David Nixon, Paul Daniels, and Tommy Cooper :)


MODE = 0 # 0 -> 2 # 0=Planar RGB8, 1= YV24, 2=Y8

frame_start= 0
frame_end = 599
FPS=60

after = Colorbars.Killaudio.Trim(frame_start,frame_End).BilinearResize(1920,1200).AssumeFPS(FPS)

Assert(0 <= MODE <= 2,"0 <= MODE <= 2")
after = Select(MODE,after.ConvertToPlanarRGB,after.ConvertToYV24,after.ConvertToY8)

before=after.FlipHorizontal

scale_factor = 2
img_width = after.Width()
img_height = before.Height()

offset_crop_v = 512
offset_crop_h = -1

after_zoomin = PointResize(after, img_width*scale_factor, img_height*scale_factor)
before_zoomin = PointResize(before, img_width*scale_factor, img_height*scale_factor)

after_zoomin_crop = Crop(after_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)
before_zoomin_crop = Crop(before_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)

subtitle_before = Subtitle(before_zoomin_crop, "FSR Ultra Quality", font = "Arial", size = 48.0, text_color=color_white, align = 3)
subtitle_after = Subtitle(after_zoomin_crop, "FSR OFF", font = "Arial", size = 48.0, text_color=color_white, align = 1)

a = subtitle_before
b = subtitle_after

Assert(a.IsPlanar,"Sorry, Planar Only")

S_RGB = "sx width time * X@ >= sx X 1 + < & 255 sx X < x y ? ?" #
S_Y = "sx width time * X@ >= sx X 1 + < & 255 sx X < x y ? ?" # Ditto
S_U = "sx width time * X@ >= sx X 1 + < & 128 sx X < x y ? ?" #
S_V = "sx width time * X@ >= sx X 1 + < & 128 sx X < x y ? ?" # Ditto

IS_RGB = (a.IsRGB)
IS_Y = (a.IsY)

SS = (IS_RGB) ? S_RGB : S_Y
S_U = !(IS_RGB||IS_Y) ? S_U : Undefined
S_V = !(IS_RGB||IS_Y) ? S_V : Undefined

Expr(a,b,SS,S_U,S_V)

Info

edison
8th July 2021, 10:28
Thanks a lot.

It works, but I need to swap the "a, b" to "b, a" to make it match the order of "before / after".


MODE = 0 # 0 -> 2 # 0=Planar RGB8, 1= YV24, 2=Y8

frame_start= 0
frame_end = 599
FPS=60

before=ImageSource ("before.png", frame_start , frame_end, FPS)

Assert(0 <= MODE <= 2,"0 <= MODE <= 2")
before = Select(MODE, before.ConvertToPlanarRGB, before.ConvertToYV24, before.ConvertToY8)

after=ImageSource ("after.png", frame_start, frame_end, FPS)
after = Select(MODE, after.ConvertToPlanarRGB, after.ConvertToYV24, after.ConvertToY8)

scale_factor = 2
img_width = after.Width()
img_height = before.Height()

offset_crop_v = 512
offset_crop_h = -1

after_zoomin = PointResize(after, img_width*scale_factor, img_height*scale_factor)
before_zoomin = PointResize(before, img_width*scale_factor, img_height*scale_factor)

after_zoomin_crop = Crop(after_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)
before_zoomin_crop = Crop(before_zoomin, ((img_width*scale_factor)/(scale_factor*2))+offset_crop_h, ((img_height*scale_factor)/(scale_factor*2))+offset_crop_v, 1920, 1200)

subtitle_before = Subtitle(before_zoomin_crop, "FSR Off", font = "Arial", size = 48.0, text_color=color_white, align = 3)
subtitle_after = Subtitle(after_zoomin_crop, "FSR Ultra Quality", font = "Arial", size = 48.0, text_color=color_white, align = 1)


a = subtitle_before
b = subtitle_after

Assert(a.IsPlanar,"Sorry, Planar Only")

S_RGB = "sx width time * X@ >= sx X 1 + < & 255 sx X < x y ? ?" #
S_Y = "sx width time * X@ >= sx X 1 + < & 255 sx X < x y ? ?" # Ditto
S_U = "sx width time * X@ >= sx X 1 + < & 128 sx X < x y ? ?" #
S_V = "sx width time * X@ >= sx X 1 + < & 128 sx X < x y ? ?" # Ditto

IS_RGB = (a.IsRGB)
IS_Y = (a.IsY)

SS = (IS_RGB) ? S_RGB : S_Y
S_U = !(IS_RGB||IS_Y) ? S_U : Undefined
S_V = !(IS_RGB||IS_Y) ? S_V : Undefined



Expr(b, a, SS, S_U, S_V)


Info