Surrealist
11th January 2008, 18:46
So... I came across the infamous(or maybe famous) Brady Bunch script, but I wanted to be able to specify where, when, and for how long certain clips were played in a PIP box. I also wanted to easily add multiple PIP boxes spread throughout a base clip.
After tinkering(and already being an experienced programmer), I think I figured out the script language and modified the Brady Bunch script to be an easy way to create the PIP effect with the least amount of hassle.
You need to make sure all clips are in the same framerate... I found that out the hard way.
To add more than one PIP clip in a single video, just load the clip and resize it... and then copy the line at the bottom with your new clip name and start position.
So... I hope someone finds this script useful, or educational. :)
And I just realized... to use this script you need a file named "blank.png" which is just a white picture. I think that the "blank.png" could be modified to give rise to various PIP shapes instead of the normal square one, but am actually totally unaware of its true function in this script... I couldn't figure out how to get rid of it...
Also, "video" and "clip1" are assumed to be the same size videos... obviously if your "clip1" is already small enough then you don't need the resize.
Here it is:
#Master video
global video = avifilesource("01.avi").ConvertToRGB32()
#PIP clips
clip1 = avifilesource("02.avi").ConvertTorgb32()
#Reduce the size of all PIP clips
clip1 = clip1.bicubicresize(width(clip1) / 4,height(clip1) / 4)
#################################################################
# calculate coordinates for PIP clips
xpos = Width(video)-Width(clip1)-20
ypos = Height(video)-Height(clip1)-20
#################################################################
#Framerate, seconds, and total length of master video
FR = video.framerate()
global Total=video.Framecount()
#Intialize mask video clip
global lblank = ImageSource("blank.png", 0, 1, FR,pixel_type = "rgb32").BilinearResize(width(video),height(video)).Loop().ConvertToRGB32()
#################################################################
# This makes moving layers possible:
Function Layer1(clip lblank, clip lvideo1, int x, int y, int w, int h)
{(lblank).Layer(lvideo1,"add",255,x,y)}
# Simplifies doing PIP clips... less code and hassle!
Function placePIP(clip PIP, int start, int x, int y)
{
video1=Animate(0,1, "Layer1" ,lblank,PIP,x,y,width(PIP),height(PIP),lblank,PIP,x,y,width(PIP),height(PIP))
videoa=video.Trim(0,int(start))
videob=video.Trim(int(start)+1,int(start + (PIP.Framecount()))).Layer(video1)
videoc=video.Trim(int(start + (PIP.framecount()))+1,Total)
video1=videoa+videob+videoc
return video1
}
#################################################################
#Add PIP for clip1
video = placePIP(clip1,110,xpos,ypos)
video
After tinkering(and already being an experienced programmer), I think I figured out the script language and modified the Brady Bunch script to be an easy way to create the PIP effect with the least amount of hassle.
You need to make sure all clips are in the same framerate... I found that out the hard way.
To add more than one PIP clip in a single video, just load the clip and resize it... and then copy the line at the bottom with your new clip name and start position.
So... I hope someone finds this script useful, or educational. :)
And I just realized... to use this script you need a file named "blank.png" which is just a white picture. I think that the "blank.png" could be modified to give rise to various PIP shapes instead of the normal square one, but am actually totally unaware of its true function in this script... I couldn't figure out how to get rid of it...
Also, "video" and "clip1" are assumed to be the same size videos... obviously if your "clip1" is already small enough then you don't need the resize.
Here it is:
#Master video
global video = avifilesource("01.avi").ConvertToRGB32()
#PIP clips
clip1 = avifilesource("02.avi").ConvertTorgb32()
#Reduce the size of all PIP clips
clip1 = clip1.bicubicresize(width(clip1) / 4,height(clip1) / 4)
#################################################################
# calculate coordinates for PIP clips
xpos = Width(video)-Width(clip1)-20
ypos = Height(video)-Height(clip1)-20
#################################################################
#Framerate, seconds, and total length of master video
FR = video.framerate()
global Total=video.Framecount()
#Intialize mask video clip
global lblank = ImageSource("blank.png", 0, 1, FR,pixel_type = "rgb32").BilinearResize(width(video),height(video)).Loop().ConvertToRGB32()
#################################################################
# This makes moving layers possible:
Function Layer1(clip lblank, clip lvideo1, int x, int y, int w, int h)
{(lblank).Layer(lvideo1,"add",255,x,y)}
# Simplifies doing PIP clips... less code and hassle!
Function placePIP(clip PIP, int start, int x, int y)
{
video1=Animate(0,1, "Layer1" ,lblank,PIP,x,y,width(PIP),height(PIP),lblank,PIP,x,y,width(PIP),height(PIP))
videoa=video.Trim(0,int(start))
videob=video.Trim(int(start)+1,int(start + (PIP.Framecount()))).Layer(video1)
videoc=video.Trim(int(start + (PIP.framecount()))+1,Total)
video1=videoa+videob+videoc
return video1
}
#################################################################
#Add PIP for clip1
video = placePIP(clip1,110,xpos,ypos)
video