Advertisement
Guest User

insertsign

a guest
Feb 21st, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # fixed ver. to deal with HD video correctly v.1.38 mod by AmjadSONY
  2.  
  3. function insertsign(clip mainclip, clip overlayclip, int startframe, int "endframe", int "xoffset", int "yoffset", clip "External") {
  4.     # make the endframe parameter optional (defaulting to where the overlay clip ends)
  5.     endframe = default(endframe,startframe+overlayclip.framecount-1)
  6.     endframe = (endframe == 0) ? startframe+overlayclip.framecount()-1 : endframe
  7.     endframe = (endframe >= mainclip.framecount()-1) ? mainclip.framecount()-1 : endframe
  8.    
  9.     # make sure the special case startframe=1 is dealt with correctly
  10.     # (needed because trim(0,0) returns the entire clip, which is obviously not what we want)
  11.     # note that the first frame of the clip is ZER0, _not_ one!
  12.     begin   = (startframe == 1) ? mainclip.trim(0,-1) : mainclip.trim(0,startframe-1)
  13.     middle  = mainclip.trim(startframe,endframe)
  14.     end = (endframe == mainclip.framecount()-1) ? blankclip(mainclip,length=0) : mainclip.trim(endframe+1,0)
  15.    
  16.     sisphbd = AvsPlusVersionNumber > 2294
  17.     shasalp = sisphbd ? middle.IsRGB64() || middle.IsRGB32() : middle.IsRGB32()
  18.     middleoverlay = shasalp ? Layer(middle,overlayclip, "add", x=xoffset, y=yoffset) : Overlay(middle, defined(External) ? External : overlayclip.IsRGB() && !(middle.IsRGB()) ? (VersionNumber() < 2.60) ? \
  19.     (mainclip.height() < 600) ?  overlayclip.ConvertToYV12() : overlayclip.ConvertToYV12(matrix="Rec709") : \
  20.     (mainclip.height() < 600) ?  sisphbd ? overlayclip.ConvertToYUV444() : overlayclip.ConvertToYV24() : sisphbd ? overlayclip.ConvertToYUV444(matrix=mainclip.BitsPerComponent() > 8 && mainclip.width() > 1440 ? "rec2020" : "Rec709") : overlayclip.ConvertToYV24(matrix="Rec709") : overlayclip, mask=overlayclip.showalpha(), x=xoffset, y=yoffset)
  21.    
  22.     # deal with the special case startframe=0 (in which case we don't have anything before the overlay)
  23.     # note that trim(-1,0) does nothing (it returns the same as trim(0,0)...)
  24.    
  25.     final = (startframe == 0) ? middleoverlay ++ end : begin ++ middleoverlay ++ end
  26.     return final
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement