View Full Version : Script for A/B splitscreen compare?
osgZach
29th June 2014, 17:17
I'm not sure what the term I'm looking for is, but I want to make a clip for my brother to review, for a Blu Ray I am working on cleaning up for him (grain removal)
I don't want to do a simple side-by-side. I would like to do a full video frame (1920x1080) with a splitscreen type effect, where the left half of the frame is the original, and the right half is filtered.
sneaker_ger
29th June 2014, 17:44
Crop away the right respectively left half and then use StackHorizontal().
raffriff42
29th June 2014, 17:59
I helps to have a black border between the two clips. Crop each clip to (half-width - 4), then add an 8-pix border in the middle.
It's also good to "pan" the cropped image if the area of interest is off center.
I've had this script a long time and it's one I still use a lot ##################################
### make side-by-side split clip (for comparison or preview)
## crop input images to fit in original width
##
## @ S - sound source [default = A]
## @ border - border subtracted from clips [default = 8]
## @ pan - range = -1.0 to +1.0: -1.0=left, 0.0=center, +1.0=right; [default = 0.0]
## @ wid - output width [default = input width]
##
function UUStackTwoAcrossCropped(clip A, clip B, clip "S",
\ int "border", float "pan", int "wid")
{
S = Default(S, A)
inWid = Default(wid, A.Width)
inHgt = Min(A.Height, B.Height)
border = _uumod(4, Default(border, 8))
border2 = Int(border / 2)
pan = Min(Max(-1.0, Float(Default(pan, 0.0))), 1.0) * 0.5
cropWid = _uumod(2, Float(inWid) / 2.0)
A = A.UUSize(cropWid-border2, inHgt)
B = B.UUSize(cropWid-border2, inHgt)
A = A.AddBorders(0, 0, border2, 0)
B = B.AddBorders(border2, 0, 0, 0)
A = StackHorizontal(A, B).UUSize(inWid, inHgt)
return (S.IsClip==false) ? A
\ : (S.AudioChannels == 0) ? A
\ : AudioDub(A, S)
}
##################################
### crop or add borders to ensure clip is a certain size
#
function UUSize(clip C, int wid, int hgt)
{
bdrWid = (wid - C.Width)
bdrHgt = (hgt - C.Height)
bdrLt = Abs(Round(Float(bdrWid) / 2.0))
bdrLt = Sign(bdrWid) * (bdrLt + (bdrLt % 2))
bdrTp = Abs(Round(Float(bdrHgt) / 2.0))
bdrTp = Sign(bdrHgt) * (bdrTp + (bdrTp % 2))
bdrRt = (bdrWid - bdrLt)
bdrBt = (bdrHgt - bdrTp)
C = C.AddBorders(
\ ((bdrLt > 0) ? bdrLt : 0),
\ ((bdrTp > 0) ? bdrTp : 0),
\ ((bdrRt > 0) ? bdrRt : 0),
\ ((bdrBt > 0) ? bdrBt : 0))
C = C.Crop(
\ ((bdrLt < 0) ? -bdrLt : 0),
\ ((bdrTp < 0) ? -bdrTp : 0),
\ ((bdrRt < 0) ? bdrRt : wid),
\ ((bdrBt < 0) ? bdrBt : hgt))
return C
}
##################################
## return argument 'f' as integer and ensure it is Mod 'm'
##
## @ m - mod value
## @ f - input (may be positive or negative)
## @ z - always mod towards zero after rounding (default true)
##
## Examples:
## _uumod(2, 3.4) == 2
## _uumod(2, 3.6) == 4
## _uumod(2, -3.4) == -2
## _uumod(2, -3.6) == -4
##
## _uumod(2, 3) == 2
## _uumod(2, 3, false) == 4
## _uumod(2, -3) == -2
## _uumod(2, -3, false) == -4
##
function _uumod(int m, float f, bool "z")
{
m = Max(1, m)
mult = Default(z, true) ? -1 : 1
fsgn = Sign(f)
i = Round(Abs(f))
return fsgn * Max(0, i + mult * (i % m))
}
osgZach
30th June 2014, 16:53
Thanks for that. Works nicely
Overdrive80
30th June 2014, 19:07
I use this:
A=Import("E:\xxx.avs").\
subtitle(string("Original")).Crop(0,0,-width/2,0)
B=Import("E:\yyy.avs").\
subtitle(string("Modificado"),align=9).Crop(2+width/2,0,0,0).AddBorders(2, 0, 0, 0,$00FFFF00)
Stackhorizontal(A,B)
Gavino
30th June 2014, 21:17
A=Import("E:\xxx.avs").\
subtitle(string("Original")).Crop(0,0,-width/2,0)
That code has a hidden 'gotcha'.
Because width() is used, it will only work if the return value from xxx.avs is the same as the final value of 'last' in that file.
Similarly with yyy.avs.
To make it work independently of how xxx.avs and yyy.avs are written, it would be better to use:
Import("E:\xxx.avs")
A = subtitle(string("Original")).Crop(0,0,-width/2,0)
Import("E:\yyy.avs")
B = subtitle(string("Modificado"),align=9).Crop(2+width/2,0,0,0).AddBorders(2, 0, 0, 0,$00FFFF00)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.