zn
20th December 2016, 01:39
Hi
I want to crop input file 1280x960 to output file 1280x720,
but I wan to move cropping window region over timeline, i.e.:
00:00:00 - video cropped from below (crop region window offset x,y=0,0)
00:01:00 - video cropped from top (crop region window offset x,y=0,240)
00:02:00 - video cropped from center (crop region window offset x,y=0,120)
How is it possible to script sequential moving of crop region window from 0,0 to 0,240 ?
How is it possible to script instant crop region window change from 0,0 to 0,240 ?
(additional note: input file is video, not still image)
StainlessS
20th December 2016, 03:39
You dont use CROP (too jerky), use some kind of resize together with Animate(). (also see ApplyRange).
This done at half size
IW=640 IH=490 OW=IW OH=360
Colorbars(Width=IW,Height=IH).Assumefps(24.0).KillAudio
Merge(FlipVertical).Merge(FlipHorizontal)
FperMin=FrameRate*60.0
Min0=Round(0*FperMin) # Frame number @ 00:00
Min1=Round(1*FperMin) # Frame number @ 01:00
Trim(0,-Min1) # 1 Minute
ShowFrameNumber
Filter="Spline36Resize"
Animate(Min0,Min1-1,Filter,
\ OW,OH, 0.0, Float(0.0) , Float(OW), Float(OH),
\ OW,OH, 0.0, Float(IH-OH), Float(OW), Float(OH)
\ )
Info
EDIT: Above, edited, changed to 24FPS (get rid of 29.97) and added Info and ShowFrameNumber.
Above only does 1 minute. [NOTE above Float()'s to make explicit that floats are needed there]
Search on Animate and ApplyRange for better examples.
On wiki, http://avisynth.nl/index.php/Animate
EDIT: Also see here:- http://forum.doom9.org/showthread.php?t=166736&highlight=animate
raffriff42
20th December 2016, 03:43
Here are some previous threads on this topic - have a look:
http://forum.doom9.org/showthread.php?t=135776 ("KenBurnsEffect")
http://forum.doom9.org/showthread.php?t=168423 ("slow tilt")
http://forum.doom9.org/showthread.php?t=172566 ("moving crop")
StainlessS
20th December 2016, 07:28
Had another go (NOTE, w1,w2 and h1,h2 default to 0.0 ie means full [EDIT: INPUT] size).
Function AniSz(clip c,Int W,Int H,
\ Int "S", Int "E",
\ Float "x1", Float "y1",Float "w1",Float "h1",
\ Float "x2", Float "y2",Float "w2",Float "h2",
\ String "Resizer"
\ ) {
/*
AniSz(W,H) # Entire clip
AniSz(W,H, 0,0) # Entire clip
AniSz(W,H, 100,0) # Frame 100 to End of Clip
AniSz(W,H, 1,1) # Frame 1 Only
AniSz(W,H, 1,-3) # Frames 1 to 3 (ie 3 frames)
AniSz(W,H, 100,200) # Frames 100 to 200
Returns Range S,E ONLY
*/
c FC=FrameCount
S = Min(Max(Default(S,0),0),FC-1)
E = Default(E,0)
E = (E==0) ? FC-1 : E
E = Min(((E < 0) ? S-E-1 : E),FC-1)
Trim(S,E)
Resizer=Default(Resizer,"Spline36Resize")
x1=Float(Default(x1,0)) y1=Float(Default(y1,0)) w1=Float(Default(w1,0)) h1=Float(Default(h1,0))
x2=Float(Default(x2,0)) y2=Float(Default(y2,0)) w2=Float(Default(w2,0)) h2=Float(Default(h2,0))
w1=(w1 <= 0.0) ? w1+Width-x1 : w1 h1=(h1 <= 0.0) ? h1+Height-y1 : h1
w2=(w2 <= 0.0) ? w2+Width-x2 : w2 h2=(h2 <= 0.0) ? h2+Height-y2 : h2
Animate(0,FrameCount-1,Resizer, W,H, x1, y1, w1, h1, W,H, x2, y2, w2, h2)
}
###
### Added Stub function : Using Fixed Input frame area WxH same as output area WxH
###
Function AniSz2(clip c,Int W,Int H,Int "S",Int "E",Float "x1",Float "y1",Float "x2",Float "y2",String "Resizer")
{c.AniSz(W,H,S,E,x1,y1,W,H,x2,y2,W,H,Resizer)}
###
###
###
Colorbars(Width=1280,Height=960).Assumefps(24.0).KillAudio
W=1280 H=720
Merge(FlipVertical).Merge(FlipHorizontal)
FperMin=FrameRate*60.0
Min0=Round(0*FperMin) # Frame number @ 00:00
Min1=Round(1*FperMin) # Frame number @ 01:00
Min2=Round(2*FperMin) # Frame number @ 02:00
Trim(0,-Min2) # 2 Minute
Subtitle("Top Lump",Size=64,align=8).Subtitle("Bot Lump",Size=64,align=2).ShowFrameNumber.Info
###
###
###
AniSz(W,H,Min0,Min1-1,y1=0,h1=H,y2=240,h2=H) + AniSz(W,H,Min1,Min2-1,y1=240,h1=H,y2=120,h2=H)
###
### Alternative using Stub.
###
#AniSz2(W,H,Min0,Min1-1,y1=0,y2=240) + AniSz2(W,H,Min1,Min2-1,y1=240,y2=120)
###
### Zooming
###
#AniSz(W,H,Min0,Min1-1,x2=320,y2=245,w2=640,h2=490) # Zoom in
#AniSz(W,H,Min0,Min1-1,x1=320,y1=245,w1=640,h1=490) # Zoom Out
#AniSz(W,H,Min0,Min1-1,w2=64,h2=49) # Zoom in on Info
#AniSz(W,H,Min0,Min1-1,w1=64,h1=49) # Zoom out from Info
EDITED:
zn
20th December 2016, 10:38
Thanks, looks good, I will try it.
For 48fps input video & 48fps output video I will change value to "Assumefps(48.0)"
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.