mel2000
29th September 2017, 06:29
Windows 10, Avisynth 2.6.0
I'd like to simultaneously overlay 3 of the same rectangles upon different coordinates of a video during the same frames. I've tried many combinations but none work. I can only get one rectangle to display even if I set a different variable for each rectangle. Can someone help me amend my script toward my objective? Thanks.
vid1 = "mytest1.mp4" # w=540 px, h=960 px
img1 = "rect1_red.jpg"
main = DirectShowSource(vid1, audio=false)
pip=ImageSource(img1, end=main.framecount-1, fps=main.FrameRate())
x1=main.Trim(0, end=2199)
y1=Overlay(main,pip,x=20,y=400,opacity=1.0).Trim(2200, end=2903)
z1=main.Trim(2904, 0)
x1+y1+z1
StainlessS
29th September 2017, 08:35
I dont quite understand what you are aiming at, but below seems to be what you are doing (or would like to do guessing from script).
vid1 = "mytest1.mp4" # w=540 px, h=960 px
img1 = "rect1_red.jpg"
main = DirectShowSource(vid1, audio=false) # almost any other source filter is more desirable
pip = ImageSource(img1, end=0) # e=0,one frame only : Not sure that fps is necessary
c1=main.trim(0 ,2199)
c2=main.trim(2200,2903)
c3=main.trim(2904,0)
x1=c1
y1=c2.Overlay(pip,x=20,y=400,opacity=1.0) # EDIT: single frame pip used for all of the range.
z1=c3
x1+y1+z1
Above does not seem to correspond with your verbal requirement, eg '3 of the same rectangles upon different coordinates of a video during the same frames'
So, maybe you are aiming at something more like this, [EDIT: below would be my best guess]
vid1 = "mytest1.mp4" # w=540 px, h=960 px
img1 = "rect1_red.jpg"
main = DirectShowSource(vid1, audio=false) # almost any other source filter is more desirable
pip = ImageSource(img1, end=0) # e=0,one frame only : Not sure that fps is necessary
c1=main.trim(0 ,2199)
c2=main.trim(2200,2903)
c3=main.trim(2904,0)
y1=c2.Overlay(pip,x=20,y=400,opacity=1.0) # 3 different lots of coords, on frames 2200 to 2903
y2=y1.Overlay(pip,x=30,y=410,opacity=1.0)
y3=y2.Overlay(pip,x=40,y=420,opacity=1.0)
c1 + y3 + c3
Both, totally untested.
EDIT: Below is equivalent to the y1, y2, and y3, lines. (Default for Opacity is 1.0, so not actually needed)
y3=c2.Overlay(pip,x=20,y=400).Overlay(pip,x=30,y=410).Overlay(pip,x=40,y=420)
mel2000
29th September 2017, 10:42
Thank you so much for your prompt reply StainlessS. You understood exactly what I wanted and your solution worked perfectly. It was also clear and thorough enough to let me see where I went astray.
I tested with your y3 concatenated overlays and they worked as predicted too. You really taught me a lot today and your solution is definitely going into my Avisynth archives.
StainlessS
29th September 2017, 16:14
Arh, I got there, but by a bit of a detour, glad it got sorted, peace be with you :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.