VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. I have a clip overlayed on top of another one in the center of the frame for a picture on picture effect. I would like to add a transition to it, so it doesn't just appear, but wipes into view within a few seconds. I looked into the TransAll plugin, but I get an error that the "there is no function named TransWipe". How can I add this effect to the overlay? Thanks.
    Last edited by videeo; 28th Jan 2018 at 02:05.
    Quote Quote  
  2. You probably did not load the plugin correctly. Either place the DLL in your autoload directory or load the plugin with an explicit call as shown below.

    Here is a basic script demonstrating TransWipe.
    Code:
    LoadPlugin("<path>\TransAll.dll") ## edit <path> to actual location of DLL
    
    ## example clip A = no overlay.
    A=Colorbars
    
    ## temporarily show frame numbers to make sure no frames are skipped or repeated
    A=A.ShowFrameNumber(x=16, y=16)
    
    ## example clip B = A + overlay. In this case the overlay is text.
    B=A.Subtitle("B", size=A.Height, align=2)
    
    ## optional - temporarily make B a negative image to show exactly when the wipe begins 
    #B=B.Invert
    
    ## TransAll 'overlap' argument: frames if positive, seconds if negative
    wipe_time=30 ## frames
    
    ## start of wipe in frames
    wipe_start=100
    
    ## wipe clip B on screen, left to right
    TransWipe(
    \    A.Trim(0, wipe_start+wipe_time), 
    \    B.Trim(wipe_start+1, 0), 
    \    wipe_time, 
    \    "right" )
    return Last
    Last edited by raffriff42; 28th Jan 2018 at 15:05. Reason: make Invert optional
    Quote Quote  
  3. Thanks raffriff42. I tried your script after I found I was missing some runtime libraries for TransAll to work properly. The overlay is actually the clip being transitioned. I am guessing somehow I have to specify a clip that can be made transparent. Here's a diagram of what I am trying to do:

    Image
    [Attachment 44524 - Click to enlarge]
    Quote Quote  
  4. Use my script with "right" changed to "left."
    As I explain in the script, you need two copies of the clip - one without the overlay, one with the overlay.
    You wipe from one to the other.

    Image
    [Attachment 44528 - Click to enlarge]
    Quote Quote  
  5. You can do all that with the built in AviSynth functions Overlay() and Animate(). For example:

    Code:
    ######################################################
    #
    # Make an alpha mask that reveals a portion of a video
    #
    ######################################################
    
    function mk_alpha(clip c, float percent)
    {
      black = BlankClip(c, color=$000000).ColorYUV(cont_y=50)
      white = BlankClip(c, color=$ffffff).ColorYUV(cont_y=50)
    
      xpos = c.width - (int(c.width * percent / 100.0) /2 *2) # force mod 2 for YUY2 or YV12
    
      overlay(black, white, x=xpos, y=0)
    }
    
    ######################################################
    #
    # Main script
    #
    ######################################################
    
    ColorBars().ConvertToYV12().Trim(0,500)
    inner = BilinearResize(width/2, height/2) # create a second, smaller video
    
    alpha = Animate(100,199, "mk_alpha", inner,0.0, inner,100.0) # build an alpha mask that will reveal the inner video from frames 100 to 199
    
    Overlay(last, inner, x=width/4, y=height/4, mask=alpha)
    Last edited by jagabo; 28th Jan 2018 at 18:06.
    Quote Quote  
  6. Here's a variation that slides the image in from the right:

    Code:
    ######################################################
    #
    # Make an alpha mask that reveals a portion of a video
    #
    ######################################################
    
    function mk_alpha(clip c, float percent)
    {
      black = BlankClip(c, color=$000000).ColorYUV(cont_y=50)
      white = BlankClip(c, color=$ffffff).ColorYUV(cont_y=50)
    
      xpos = c.width - (int(c.width * percent / 100.0) /2 *2) # force mod 2 for YUY2 or YV12
    
      overlay(black, white, x=xpos, y=0)
    }
    
    ######################################################
    #
    # Slide the image in from the right
    #
    ######################################################
    
    
    function mk_overlay(clip c, float percent)
    {
      xpos = c.width - (int(c.width * percent / 100.0))# /2 *2)
    
      Overlay(c, c, x=xpos, y=0)
    }
    
    ######################################################
    #
    # Main script
    #
    ######################################################
    
    
    ColorBars().ConvertToYV12().Trim(0,500) # make a video
    inner = BilinearResize(width/2, height/2) # create a second, smaller video
    
    alpha = Animate(100,199, "mk_alpha", inner,0.0, inner,100.0) # build an alpha mask that will reveal the inner video from frames 100 to 199
    ovr = Animate(100,200, "mk_overlay", inner,0.0, inner,100.0) # slide the image in from the right
    
    Overlay(last, ovr, x=width/4, y=height/4, mask=alpha)
    Quote Quote  
  7. Very well sir You force me to post my own script, which features an adjustable soft edge.

    Image
    [Attachment 44536 - Click to enlarge]

    Code:
    /*
    ## (sample usage)
    ## wipe duration: frames if positive, seconds if negative
    wipe_time=30
    
    ## start of wipe.
    wipe_start=100
    
    SoftWipe(
    \   A.Trim(0, wipe_start+wipe_time), 
    \   B.Trim(wipe_start+1, 0), 
    \   wipe_time, 
    \   "RightToLeft",
    \   2, 10, 100
    \ )
    return Last
    */
    
    ##################################
    ### Soft wipe; dissolve with a Wipe transition.
    ##
    ## @ A            - starting clip 
    ## @ B            - ending clip
    ## @ overlap      - overlapped frames; if negative, overlapped seconds
    ## @ Mode         - (LeftToRight|RightToLeft|TopToBottom|BottomToTop)
    ## @ Hardness      - 2=soft; 10=medium; 100=hard; default 2
    ## @ HardnessStart - 1=blur; 100=sharp; default 50
    ## @ HardnessEnd   - 1=blur; 100=sharp; default 50
    ##
    function SoftWipe(clip A, clip B, float "overlap", 
    \               string "Mode", float "Hardness",
    \               float "HardnessStart", float "HardnessEnd",
    \               bool "showmask")
    {
        Assert(!A.IsYV411, 
        \  "SoftWipe: clip 'A' is YV411 (not accepted)") ## (cf. Overlay)
        Assert(!B.IsYV411, 
        \  "SoftWipe: clip 'B' is YV411 (not accepted)")
        ## Set Defaults
        overlap       = Default(overlap, -30.0)
        wid           = A.Width
        hgt           = A.Height
        Mode          = Default(Mode, "LeftToRight")
        Hardness      = Float(Default(Hardness, 2.0))
        HardnessStart = Default(HardnessStart, 50.0)
        HardnessEnd   = Default(HardnessEnd, HardnessStart)
        showmask      = Default(showmask, false)
    
        ## try to make width of soft edge equal for hor & vert wipes:
        win_w   = Hardness * Pow(Float(wid) / hgt, 0.5) 
        win_h   = Hardness * Pow(Float(hgt) / wid, 0.5) 
    
        frms = (overlap>=0) 
        \ ? Round(overlap) 
        \ : -Round(overlap*A.FrameRate)
        AudioMix = Dissolve(A, B, frms).KillVideo
        A = A.KillAudio
        B = B.KillAudio
    
        A = (showmask) ? BlankClip(A, color=$000000) : A
        B = (showmask) ? BlankClip(B, color=$ffffff) : B
    
        ## Check Input
        Assert(Mode=="LeftToRight" || Mode=="RightToLeft" || Mode=="TopToBottom" || Mode=="BottomToTop", 
        \   "SoftWipe: allowed Mode values LeftToRight|RightToLeft|TopToBottom|BottomToTop.")
        Assert(frms < A.Framecount, 
        \   ("SoftWipe: overlap [$f] must be less than clip A length [$a]")
        \    .ReplaceStr("$f", String(frms))
        \    .ReplaceStr("$a", String(A.Framecount))
        \ )
        Assert(frms < B.Framecount, 
        \   ("SoftWipe: overlap [$f] must be less than clip B length [$b]")
        \    .ReplaceStr("$f", String(frms))
        \    .ReplaceStr("$b", String(B.Framecount))
        \ )
    
        ## Set Parameters
        aMid = Trim(A, FrameCount(A)-frms, 0)
        bMid = Trim(B, 0, -frms)
        (Mode=="RightToLeft") ? Eval("""
            BlankWidth = Int(4 / 2 * win_w)   
            BlankHeight = hgt
            startX1 = 1.5
            endX1 = BlankWidth + 0.5
            startY1 = 0
            endY1 = 0
            x2 = win_w * 2 - 2
            y2 = 0  
            ClipLeft = aMid
            ClipRight = bMid
        """)
        \ : (Mode=="TopToBottom") ? Eval("""
            BlankWidth = wid    
            BlankHeight = Int(6 / 2 * win_h)
            startX1 = 0
            endX1 = 0
            startY1 = BlankHeight + 0.5
            endY1 = 3.5
            x2 = 0
            y2 = win_h * 3 - 4 
            ClipLeft = bMid
            ClipRight = aMid
        """)
        \ : (Mode=="BottomToTop") ? Eval("""
            BlankWidth = wid    
            BlankHeight = Int(6 / 2 * win_h)
            startX1 = 0
            endX1 = 0
            startY1 = 3.5
            endY1 = BlankHeight + 0.5
            x2 = 0
            y2 = win_h * 3 - 4 
            ClipLeft = aMid
            ClipRight = bMid
        """) 
        \ : Eval(""" ## (Mode=="LeftToRight") 
            BlankWidth = Int(4 / 2 * win_w)   
            BlankHeight = hgt
            startX1 = BlankWidth + 0.5
            endX1 = 1.5
            startY1 = 0
            endY1 = 0
            x2 = win_w * 2 - 2
            y2 = 0  
            ClipLeft = bMid
            ClipRight = aMid
        """) 
    
        ## Make Mask
        BlackBar = BlankClip(A, length=frms+2, 
        \           width=BlankWidth, height=BlankHeight, 
        \           pixel_type="RGB32")
        WhiteBar = BlankClip(BlackBar, color=$FFFFFF)
        BWmask = (Mode=="LeftToRight" || Mode=="RightToLeft")
        \   ? StackHorizontal(BlackBar, WhiteBar) 
        \   : StackVertical  (BlackBar, WhiteBar) 
        BWmask = BWmask.Animate(0, frms+1, "GaussResize",
        \       wid, hgt, startX1, startY1, x2, y2, HardnessStart,
        \       wid, hgt, endX1,   endY1,   x2, y2, HardnessEnd
        \ ).Trim(1, frms)
    
        ## Glue it together
        Trim(A, 0, FrameCount(A)-frms-1)
        (frms > 0 )
        \   ? Last + Overlay(ClipLeft, ClipRight, mask=BWmask, pc_range=True) 
        \             [*  .Subtitle("win_w="+String(win_w)+"; win_h="+String(win_h)) *]
        \   : Last
        
        Last + Trim(B, frms, 0)
        HasAudio(AudioMix) 
        \   ? AudioDub(last, AudioMix) 
        \   : last
    
        function ReplaceStr(string base, string sought, string repstr) {
            pos = FindStr(base, sought)
            return (sought=="" || pos==0) ? base : ReplaceStr(
            \       LeftStr(base, pos-1) + repstr +
            \       MidStr(base, pos+StrLen(sought)),
            \       sought, repstr)
        }
    }
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!