I'm trying to create an AviSynth script that replaces one shot in a video using one image.
How do I start zoomed in on the image, then gradually zoom out?
Does anyone have a script example or tutorial I could take a look at?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 15 of 15
Thread
-
-
Is it the "Zoom overlay 1" example? My image shows up, but there is no zoom happening--the image is motionless.
Here's my script:
Code:LoadPlugin("C:\DVD\DGDecode.dll") Function myfunc(clip clip1, clip ovl4, int x, int y, int w, int h) { w = w - w%2 h = h - h%2 my_ovl4 = BicubicResize(ovl4,w,h) Overlay(clip1,my_ovl4,x,y) } clip1 = MPEG2Source("C:\DVD\02\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl4 = ImageSource("C:\Images\02.png").BicubicResize(720,480) Animate(0,158,"myfunc", \ clip1,ovl4, 10, 10, 10, 10, \ clip1,ovl4,300,300,360,288) ovl4 = ovl4.ConvertToYV12() clip2.Trim(25,2720)FadeOut(19) + clip1.Trim(2697,25188) + clip1.Trim(25189,25347).Overlay(ovl4) + clip1.Trim(25348,0)
-
Same issue as in your other thread, Overlay() is not using the proper arguments
Break it down to simpler script, before adding other things
Code:LoadPlugin("C:\DVD\DGDecode.dll") Function myfunc(clip clip1, clip ovl4, int x, int y, int w, int h) { w = w - w%2 h = h - h%2 my_ovl4 = BicubicResize(ovl4,w,h) Overlay(clip1,my_ovl4,x,y) } clip1 = MPEG2Source("C:\DVD\02\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl4 = ImageSource("C:\Images\02.png").BicubicResize(720,480).ConvertToYV12() Animate(0,158,"myfunc", \ clip1,ovl4, 10, 10, 10, 10, \ clip1,ovl4,300,300,360,288)
-
Thank you! It's working now, but the zoom is pretty jumpy (it looks like it's alternating between resizing on the x-axis and resizing on the y-axis). Am I not specifying the framerate correctly?
Code:LoadPlugin("C:\DVD\DGDecode.dll") Function myfunc(clip clip1, clip ovl4, int x, int y, int w, int h) { w = w - w%2 h = h - h%2 my_ovl4 = BicubicResize(ovl4,w,h) Overlay(clip1,my_ovl4,x,y) } clip1 = MPEG2Source("C:\DVD\02\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl4 = ImageSource("C:\Images\02.png", fps=clip1.framerate).BicubicResize(720,480).ConvertToYV12() ovl4 = Animate(0,158,"myfunc", \ clip1,ovl4,-55,-36,838,559, \ clip1,ovl4,0,0,720,480) clip2.Trim(25,2720)FadeOut(19) + clip1.Trim(2697,25188) + clip1.Trim(25189,25347).Overlay(ovl4) + clip1.Trim(25348,0)
-
Is the reason I can't get a smooth zoom because the resize animation is moving in increments smaller than 1 pixel per frame? Or because I'm not implementing subpixel resampling? Or because I'm not using floating points?
Current script:
Code:LoadPlugin("C:\DGDecode.dll") clip1 = MPEG2Source("C:\1\VTS_01_1.d2v") clip2 = MPEG2Source("C:\2\VTS_01_1.d2v") ovl1 = ImageSource("C:\Images\1.png", fps=clip1.framerate).BicubicResize(720,480).ConvertToYV12 Function myfunc(clip clip1, clip ovl1, int x, int y, int w, int h) { w = w - w%2 h = h - h%2 my_ovl1 = BicubicResize(ovl1,w,h) Overlay(clip1,my_ovl1,x,y) } ovl1 = Animate(2,158,"myfunc", \ clip1,ovl1,-55,-36,838,559, \ clip1,ovl1,0,0,720,480) clip2.Trim(25,2720).FadeOut0(19) + \ clip1.Trim(2696,25188) + \ clip1.Trim(25189,25346).Overlay(ovl1) + \ clip1.Trim(25347,0)
I'm trying to replace a shot in a video with an image, and apply a zoom effect to it that mimics a camera zooming out. My current script uses resizing animation to simulate the motion of the zoom. The problem I'm having is that the animation of the resize isn't smooth. The image constantly jitters as it changes size.
Software:
AviSynth 2.6
VirtualDub-1.10.4
Specs:
Windows 7 Professional, 64-bit
AMD Phenom(tm) II X6 1090T Processor 3.21 GHz
AMD 6870
AMD 6850
8.00 GB RAM -
You need to adjust src_left, src_top, src_width and src_height to get a smooth zoom. The math is a little tricky,
but the excellent ZoomBox script handles it for you.
It adds black borders as needed to maintain the same dimensions as the source clip.
It also does panning at the same time - some examples here.
Minimum practical size is 8x8. Contrary to the docs, Zoom.dll is not needed for simple zoom/pan without rotation.
Compatible with AVS and AVS+, 32/64bit. Note, if using AVS+, r2664 or later is needed for resizing in an Animate call.
Code:Import("<path>\ZoomBox.avsi") <Last = RGB32> ## zoom in from 0.01x to 1.0x Animate(0, 120, "myfunc", 0.01, 1.0) return Last function myfunc(clip C, float f) { f = Pow(f, 2.0) ## speed up as size gets larger return C.SimpleZoomBox(f) } ############################### ### zoom an image with pan & tilt ## wraps call to ZoomBox with fewer arguments for easier animation ## ## @ factor - range ~ 0.01 to 100 [default = 1.0] ## @ pan - location in source which will be centered in target: ## < 0.0=left, 0.0=center, > 0.0=right [default = 0.0] ## @ tilt - location in source which will be centered in target: ## < 0.0=up, 0.0=center, > 0.0=down [default = 0.0] ## function SimpleZoomBox(clip C, float factor, float "pan", float "tilt") { Assert(C.IsRGB32, "SimpleZoomBox: clip must be RGB32") factor = Min(Max(8.0/C.Height, Float(Default(factor, 1.0))), 100.0) pan = Float(Default(pan, 0.0)) tilt = Float(Default(tilt, 0.0)) offsetX = -(0.5 * pan * Float(C.Width)) offsetY = -(0.5 * tilt * Float(C.Height)) C = C.ZoomBox( \ zoomFactor=(factor * 100.0), \ ResizeMethod="Spline16Resize", \ panX=offsetX, panY=offsetY) return C }
Last edited by raffriff42; 31st Mar 2018 at 09:37.
-
Thank you, the Zoombox zoom looks really smooth!
There are two things though that I'm having trouble with using Zoombox:- How do I apply the zoom to just the ovl1 portion of my clip?
- How do I offset the x and y axes before zooming out? (I see how to do it after zooming out.)
My current script:
Code:LoadPlugin("C:\DGDecode.dll") clip1 = MPEG2Source("C:\1\VTS_01_1.d2v") clip2 = MPEG2Source("C:\2\VTS_01_1.d2v") clip1 = clip1.ConvertToRGB clip2 = clip2.ConvertToRGB ovl1 = ImageSource("C:\Images\1.png") ovl1 = ovl1.ConvertToRGB clip2.Trim(25,2720).FadeOut0(19) + \ clip1.Trim(2696,25188) + \ clip1.Trim(25189,25346).Overlay(ovl1) + \ clip1.Trim(25347,0) Animate(2, 158, "myfunc", 1.3554456019, 1.0) return Last function myfunc(clip C, float f) { f = Pow(f, 2.0) return C.SimpleZoomBox(f) } function SimpleZoomBox(clip C, float factor, float "pan", float "tilt") { Assert(C.IsRGB32, "SimpleZoomBox: clip must be RGB32") factor = Min(Max(8.0/C.Height, Float(Default(factor, 1.0))), 100.0) pan = Float(Default(pan, 0.0)) tilt = Float(Default(tilt, 0.0)) offsetX = -(0.5 * pan * Float(C.Width)) offsetY = -(0.5 * tilt * Float(C.Height)) C = C.ZoomBox( \ zoomFactor=(factor * 100.0), \ ResizeMethod="Spline16Resize", \ panX=offsetX, panY=offsetY) return C }
-
>1. How do I apply the zoom to just the ovl1 portion of my clip?
Not sure what you mean, but I'm guessing you want the image to start small and zoom in over a non-zooming background.
You create a mask clip so the black borders on ovl1 are transparent. Something like this (not tested!)Code:clip1 = MPEG2Source("C:\1\VTS_01_1.d2v") clip2 = MPEG2Source("C:\2\VTS_01_1.d2v") clip1 = clip1.ConvertToRGB clip2 = clip2.ConvertToRGB ovl1 = ImageSource("C:\Images\1.png") ovl1 = ovl1.ConvertToRGB ovl1Z = ovl1.Animate(2, 158, "myfunc", 1.3554456019, 1.0) ovl1M = BlankClip(ovl1, color=$ffffff) \ .Animate(2, 158, "myfunc", 1.3554456019, 1.0) clip2.Trim(25,2720).FadeOut0(19) + \ clip1.Trim(2696,25188) + \ clip1.Trim(25189,25346).Overlay(ovl1Z, mask=ovl1M) + \ clip1.Trim(25347,0) #Animate(2, 158, "myfunc", 1.3554456019, 1.0) return Last
>2. How do I offset the x and y axes before zooming out? (I see how to do it after zooming out.)
You can animate the pan and tilt arguments as well as zoom. Since you're doing that, you might as well animate
SimpleZoomBox directly instead of wrapping it in myfunc.
Something like this (not tested!)Code:ovl1Z = ovl1.Animate(2, 158, "SimpleZoomBox", \ 1.3554456019, -1.0, -1.0, [* start zoom, pan, tilt *] \ 1.0, 0.0, 0.0 [* end zoom, pan, tilt *] \ )
-
Thanks for your help, but unfortunately, I'm getting the following error message with each of your two examples:
Code:ovl1Z = ovl1.Animate(2, 158, "myfunc", 1.3554456019, 1.0)
Code:\ )
-
OK this script "works" in that it does not raise an error.
Diagnostic & temporary code left in, in case it helps you.
EDIT - I exaggerated the zoom & pan for testing purposes.Code:clip1 = ColorBarsHD(width=640, height=400) clip2 = clip1.Invert.FlipVertical ovl1 = clip1.ColorYUV(showyuv=true) ovl1 = ovl1.BilinearResize(clip1.Width, clip1.Height) \ .Subtitle("O", size=0.9*ovl1.Height, align=2) \ .Letterbox(8, 8, 8, 8) clip1 = clip1.ConvertToRGB clip2 = clip2.ConvertToRGB ovl1 = ovl1.ConvertToRGB #return ovl1 clip1 = clip1.ConvertToRGB.ShowFrameNumber(x=16, y=24) clip2 = clip2.ConvertToRGB.ShowFrameNumber(x=16, y=80) ovl1 = ovl1.ConvertToRGB.ShowFrameNumber(x=16, y=160) #ovl1Z = ovl1.Animate(2, 158, "myfunc", 1.3554456019, 1.0) # #ovl1M = BlankClip(ovl1, color=$ffffff) #\ .Animate(2, 158, "myfunc", 1.3554456019, 1.0) ovl1Z = ovl1.Animate(2, 158, "SimpleZoomBox", \ 2.0, -3.0, 0.0, [* start zoom, pan, tilt *] \ 0.5, 0.5, 0.0 [* end zoom, pan, tilt *] \ ) #.Trim(0, length=160) ovl1M = BlankClip(ovl1, color=$ffffff) \ .Animate(2, 158, "SimpleZoomBox", \ 2.0, -3.0, 0.0, [* start zoom, pan, tilt *] \ 0.5, 0.5, 0.0 [* end zoom, pan, tilt *] \ ) #.Trim(0, length=160) #return ovl1M clip1.Trim(25189,25346).Overlay(ovl1Z, mask=ovl1M) ovl1clip = Last #return Last clip2.Trim(25,2720).FadeOut0(19) + \ clip1.Trim(2696,25188) + \ ovl1clip + \ clip1.Trim(25347,0) return Last
[Attachment 45073 - Click to enlarge]
[Attachment 45074 - Click to enlarge]Last edited by raffriff42; 1st Apr 2018 at 18:19.
-
Thanks again, but I'm still getting the same error with this:
Code:\ )
-
Complete script please? Are you using the script I posted above? It does not have that line...
The line closes parentheses from a function call above it when arguments are placed on separate lines. For example:Code:a = x( \ y, \ z \ )
Code:a = x( \ y, \ z)
Code:a = x(y, z)
Code:a = x(y, z) \ )
Code:a = x(y, z) )
Last edited by raffriff42; 1st Apr 2018 at 22:53.
-
-
This
Code:\ ) #.Trim(0, length=160)
The "Invalid arguments to function X" error is very annoying. You need to check all arguments and make sure they are the right type (clip, string, float or int) as per the function declaration. (link)
For example, to check the first argument to Animate, you need to verify that the first argument, ovl1 , contains a valid clip at that point in the script:Code:return ovl1 ovl1Z = ovl1.Animate(2, 158, "SimpleZoomBox", \ 2.0, -3.0, 0.0, [* start zoom, pan, tilt *] \ 0.5, 0.5, 0.0 [* end zoom, pan, tilt *] \ ) #.Trim(0, length=160)
Last edited by raffriff42; 2nd Apr 2018 at 16:31.
Similar Threads
-
Zooming 'Gutterboxed' also zooms Subtitles
By cornemuse in forum SubtitleReplies: 1Last Post: 14th Oct 2014, 03:14 -
Zooming letterboxed DVDs - which is better, BD player or TV settings?
By Xoanon in forum DVD & Blu-ray PlayersReplies: 14Last Post: 2nd Jun 2014, 18:36 -
Re-authoring DVD, zooming in.
By Scryb Sprite in forum Authoring (DVD)Replies: 7Last Post: 10th Feb 2014, 08:51 -
zooming in on a part of a video or photo
By snafubaby in forum Newbie / General discussionsReplies: 1Last Post: 2nd Feb 2013, 23:48 -
Limiting the amount of zooming After Effects is doing during stabilization?
By kingmustard123 in forum EditingReplies: 3Last Post: 3rd Jul 2011, 10:12