View Full Version : Simple task? Shifting frames around
ydobon
19th September 2007, 22:44
Hi,
I'm interested in shifting some frames in a video a few pixels left or right. I've found the AddBorders+Crop trick (http://avisynth.org/mediawiki/AddBorders) but to apply it to just some frames I've only found ApplyRange and I can't/don't know how to apply both filters sequentially (and ApplyRange complains about resolution changes). :rolleyes:
I can only think in splitting the video in dozens of clips, shift each one around and re-join them. Is there a simpler way to do this? :confused:
I wish AddBorders would admit negative parameters. :D
IanB
20th September 2007, 06:55
Use Add mode with X and Y in Layer (YUY2, RGB32) or Overlay (YV12) to position the source clip over a blank clip at 100% opacity.
Use a function to group several statements for ApplyRange etc.
Look at JDL utils for more comprehensive range selection.
ydobon
20th September 2007, 07:41
First of all, thanks for your quick answer.
I've just got it working with Overlay (the video in question is YV12) once I was able to get past an "invalid parameters" error:
ApplyRange(black_bg,606,658,"Overlay",clip,-3,-1)
Now I have to try statement grouping to make it zoom in the overlayed clip. :p
Thanks again.
DarkT
20th September 2007, 12:48
I dunno, the way I'd go about it is Trim it, apply the modifications, and then combine back...
So like:
A = trim(0,50)
B = Trim(51,100).Crop(x).Addborders/Resize/whatever
C = A+B
Return C
It's prolly a noobish way of going about it, but anyway...
Edit:
A simpler way would be:
ReplaceFramesSimple(Trim(a,b,-c,-d),
\ mappings="[645 706] ")
It's one of StickyBoy's functions... This would apply the Trim to frames 645 to 706...
Naturally, keep the overall resolution the same, otherwise it won't let ya...
midelic
20th September 2007, 14:59
It looks like warpsharp(shodan version)shifts frames to the upper left side.
see:
That difference picture of WarpSharp is misleading. This particular Warpsharp version does something very strange: it shifts the whole frame to the upper-left. Check "interleave(clip,clip.WarpSharp())" to confirm. Therefore, those "big differences" you see are not caused by more sharpening; they are caused by the spatial shifting of WarpSharp.
http://forum.doom9.org/showthread.php?t=129818
foxyshadis
20th September 2007, 15:02
If you call one of the resizers like Resize(width,height,src_left=x,src_top=y,src_width=width,src_height=height) as seen in this thread (http://forum.doom9.org/showthread.php?t=127909), you get no complaints of frame size, and it works nicely in conditional. Mind IanB's warning, but I never found it to be very resource intensive.
ydobon
21st September 2007, 07:05
Thank you all for your help.
Once I've learned to use Overlay and ApplyRange, I've ended using it for everything :D
I've done what I wanted with the video (shifting several segments in one or two of the four directions and/or zooming in) with a couple of functions:
function ShiftFrames(clip clip, int "start", int "end", int "x", int "y") {
ApplyRange(clip, start, end, "Overlay", clip, x, y)
}
function Zoom(clip clip, int "start", int "end", int "zoom") {
zoomed = Lanczos4Resize(clip, 720+zoom*8, 576+zoom*6)
ApplyRange(clip, start, end, "Overlay", zoomed, -zoom*4, -zoom*3)
}
Once "fixed", the video has been cropped. That's why I didn't bother to use a blank clip in the overlay (which would have been a cleaner solution).
stickboy
22nd September 2007, 04:47
I'm interested in shifting some frames in a video a few pixels left or right. I've found the AddBorders+Crop trick (http://avisynth.org/mediawiki/AddBorders) but to apply it to just some frames I've only found ApplyRange and I can't/don't know how to apply both filters sequentially (and ApplyRange complains about resolution changes).In general, if you want to apply multiple filters like that, you can create your own user-defined function that applies all of them, and then you pass your function to ApplyRange.
For example:
function Shift(clip c, ...)
{
return c.AddBorders(...).Crop(...)
}
AVISource("example.avi")
ApplyRange(100, 200, "Shift", ...)(I leave it as an exercise for the reader to fill in the "..." parts appropriately.)
ydobon
22nd September 2007, 08:03
Thanks for the code example.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.