PDA

View Full Version : Avisynth: frame interpolate + stitch clips together


D9JK
16th June 2010, 21:32
Hello all,

I just recently started learning how to use Avisynth, and here's something I'm currently trying to figure out:


If the code (not written by me, by the way) for motion smoothing / frame interpolation is this...

LoadPlugin("C:\Program Files\AVISynth\Plugins\mvtools.dll")
source = DirectShowSource ("1.mov")
oSource = source
source = AssumeFPS (source,20)
backward_vec = source.MVAnalyse (isb = true, truemotion=true, pel=2, idx=1)
forward_vec = source.MVAnalyse (isb = false, truemotion=true, pel=2, idx=1)
cropped = source.crop (4,4,-4,-4) # by half of block size 8
backward_vec2 = cropped.MVAnalyse (isb = true, truemotion=true, pel=2, idx=2)
forward_vec2 = cropped.MVAnalyse (isb = false, truemotion=true, pel=2, idx=2)
fSource = source.MVFlowFps2 (backward_vec,forward_vec,backward_vec2,forward_vec2,num=60,idx=1,idx2=2)
fSource = AssumeFPS (fSource,60)
return fSource


... and the code for stitching multiple video clips together is something like this (if I'm not mistaken)...

DirectShowSource("1.mov")
d1=last

DirectShowSource("2.mov")
d2=last

DirectShowSource("3.mov")
d3=last

d1++d2++d3


... then how would I combine the two?

In other words, I'm trying to make Avisynth first motion smooth / frame interpolate all video clips, and then stitch them together into a single, long clip.


I already tried something with my (very) limited knowledge, but the results are not really worth mentioning. But I assume I might have to change things like "source" and "fsource" (and "cropped"?) into "source1 and "fsource1" for each clip, so that they don't interfere with each other, when processing the next clips, right? Or maybe not, you tell me.

It's the block of code required by the frame interpolation process that is confusing me, but this is probably a cakewalk for the Avisynth veterans.

onesloth
17th June 2010, 02:13
Do you want to apply the same processing to each of the three source clips?

D9JK
17th June 2010, 14:36
Yes, that would work fine, at least for now.

onesloth
17th June 2010, 17:09
Yes, that would work fine, at least for now.
mmmkay....

Are you really trying to make a 20 fps clip into 60 fps? That is to say is your source actually 20 fps?

D9JK
17th June 2010, 18:38
The source is 20 fps, yes, but the 60 fps was just a value I made up for the code. Instead, I'm thinking of doing a 20 fps -> 30 fps interpolation, because I don't really like the apparent choppiness of 20 fps.

It's not a drastic increase in smoothness, but then again, the potential visual artifacts from the interpolation shouldn't be too noticeable either.

EDIT:

Now I started wondering something. Since I'm basically multiplying the frame rate by a non-integer number (20 -> 30 = 1.5x), won't the movement in the clips look kind of unsmooth, or unconsistent, every 2nd (or 3rd?) frame? Would it be a better option to actually interpolate the frame rate into the 60 fps instead (since 20 -> 60 = 3x), and then just skip every 2nd frame, resulting in a presumably smoother looking 30 fps clips compared to how I'm currently thinking of doing this?

Just a thought.

onesloth
17th June 2010, 18:57
Now I started wondering something...
Nah, you're thinking too much.

I'm assuming the whole cropping part was to overcome some limitation of the old MVTools... Start by getting MVTools2 and then use this script:
DirectShowSource("1.mov") ++ DirectShowSource("2.mov") ++ DirectShowSource("3.mov")
super = MSuper()
backward_vec = MAnalyse(super, isb = true)
forward_vec = MAnalyse(super, isb = false)
MFlowFps(super, backward_vec, forward_vec, num=30, den=1)

D9JK
17th June 2010, 19:13
Ah, right... I was on the author's site just two days ago, but didn't notice the more recent version.

Thank you very much for the code, I thought it would be much longer! But then, what do I know. I'll go and give it a try.

foxyshadis
19th June 2010, 03:28
The original script simulates overlap, from before MVTools had it built in. Now you can use MAnalyse(super, overlap=4, isb = true) to get the exact same effect, and it'll probably look a bit better than without - but take almost twice as long, like the original script.

onesloth
19th June 2010, 05:43
The original script simulates overlap, from before MVTools had it built in.
I figured it was something like that. :stupid: For some reason I thought MAnalyse used overlap=blksize/4 or blksize/2 by default, but i doesn't, its just recommended in the docs.