Log in

View Full Version : Cloning using Avisynth


tacman1123
2nd November 2008, 03:56
I was playing around today with using Avisynth to do the cloning effect, the end result is pretty neat:

http://videothoughts.com/project/flash/single.php?fn=avisynth/chess_clone.mp4

The timing is off on the third move, and other issues, but I thought I'd share the script and ask for feedback.


source=AviSource("c:\usr\sites\vidgrab\chess_fin2.avi")
length = 26 * 30
white_start = 70
black_start = 856
a=source.Trim(white_start, -length)
b=source.Trim(black_start, -length)
divide=a.width/2
a=a.Lanczos4Resize(a.Width-divide, a.Height,0,0,divide)
b=b.Lanczos4Resize(b.Width-divide, b.Height, b.Width - divide, 0, b.Width - divide)
# a.ConvertToRGB32().Layer(b.ConvertToRGB32(), x=a.Width/2+1, op="add", level=256)
StackHorizontal(a,b).Trim(0, 560)


Is StackHorizontal() the right approach for this? I tried Layer() (and Overlay, got nowhere with that), but layer requires switching color spaces and I still had a hard time figuring out what parameters to pass.

I'm also looking for ways to make the centerline a bit smoother, something seems not quite right with it. I'm guessing it's the way I did the crop, which was done with the Resize rather than crop because of a note I read on another thread that said not to use Crop to take out a large section, it was more for edge lines.

My goal is to put scripts like this, along with a video, into an Avisynth Cookbook that Mikeytown mentioned in another script.

As always, thanks for any suggestions. Enjoy!

Tac

mikeytown2
2nd November 2008, 09:38
So you had a camera on a tripod, played chess with white, then ran over and played chess with black. You then found the cut points and went from there. Nice job!


StackHorizontal() (http://avisynth.org/mediawiki/StackHorizontal) does work for the most part, except there is a little bit of camera movement. I would opt for Overlay() (http://avisynth.org/mediawiki/Overlay) rather then Layer() (http://avisynth.org/mediawiki/Layer), if trying to go the "layer" route. Use a mask that has one side black, one side white with however many gradient pixels you want for a soft edge in the middle. You could try KBE (http://forum.doom9.org/showthread.php?t=135776) (manual) or Depan (http://avisynth.org.ru/depan/depan.html) (semi-auto) to keep the video still. Yet another option is Deshaker (http://www.guthspot.se/video/deshaker.htm).

To fix the sync you might have to change the frame rate (AssumeFPS (http://avisynth.org/mediawiki/FPS)) then convert the frame rate back (ConvertFPS (http://avisynth.org/mediawiki/FPS)) so that certain parts play back faster or slower. This is where a GUI comes in handy. Using trim might make the persons movement non natural, so keep away from it. Only use Trim for the main temporal alignment, like you are right now; trim the ending more though.

Using a resizer for the crop allows you to crop subpixels; if your not doing that then using plain old crop is a lot faster. In short you will get a hard edge with Crop() and a semi-soft edge with a Resize(). For this it really shouldn't matter in my opinion, so I would opt for crop because its faster.