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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th June 2014, 17:17   #1  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
Script for A/B splitscreen compare?

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.
osgZach is offline   Reply With Quote
Old 29th June 2014, 17:44   #2  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Crop away the right respectively left half and then use StackHorizontal().
sneaker_ger is offline   Reply With Quote
Old 29th June 2014, 17:59   #3  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
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
Code:
##################################
### 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))
}

Last edited by raffriff42; 30th June 2014 at 05:01. Reason: UUSize: bugfix
raffriff42 is offline   Reply With Quote
Old 30th June 2014, 16:53   #4  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
Thanks for that. Works nicely
osgZach is offline   Reply With Quote
Old 30th June 2014, 19:07   #5  |  Link
Overdrive80
Anime addict
 
Overdrive80's Avatar
 
Join Date: Feb 2009
Location: Spain
Posts: 673
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)
__________________
Intel i7-6700K + Noctua NH-D15 + Z170A XPower G. Titanium + Kingston HyperX Savage DDR4 2x8GB + Radeon RX580 8GB DDR5 + ADATA SX8200 Pro 1 TB + Antec EDG750 80 Plus Gold Mod + Corsair 780T Graphite
Overdrive80 is offline   Reply With Quote
Old 30th June 2014, 21:17   #6  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Overdrive80 View Post
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)
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.