Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th June 2010, 21:32   #1  |  Link
D9JK
Registered User
 
Join Date: Feb 2010
Posts: 41
Avisynth: frame interpolate + stitch clips together

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...

Code:
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)...

Code:
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.
D9JK is offline   Reply With Quote
Old 17th June 2010, 02:13   #2  |  Link
onesloth
Registered User
 
Join Date: Jul 2007
Posts: 137
Do you want to apply the same processing to each of the three source clips?
onesloth is offline   Reply With Quote
Old 17th June 2010, 14:36   #3  |  Link
D9JK
Registered User
 
Join Date: Feb 2010
Posts: 41
Yes, that would work fine, at least for now.
D9JK is offline   Reply With Quote
Old 17th June 2010, 17:09   #4  |  Link
onesloth
Registered User
 
Join Date: Jul 2007
Posts: 137
Quote:
Originally Posted by D9JK View Post
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?
onesloth is offline   Reply With Quote
Old 17th June 2010, 18:38   #5  |  Link
D9JK
Registered User
 
Join Date: Feb 2010
Posts: 41
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.

Last edited by D9JK; 17th June 2010 at 18:51.
D9JK is offline   Reply With Quote
Old 17th June 2010, 18:57   #6  |  Link
onesloth
Registered User
 
Join Date: Jul 2007
Posts: 137
Quote:
Originally Posted by D9JK View Post
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:
Code:
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)
onesloth is offline   Reply With Quote
Old 17th June 2010, 19:13   #7  |  Link
D9JK
Registered User
 
Join Date: Feb 2010
Posts: 41
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.
D9JK is offline   Reply With Quote
Old 19th June 2010, 03:28   #8  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,175
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.
__________________
There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. ~ Ed Howdershelt
foxyshadis is offline   Reply With Quote
Old 19th June 2010, 05:43   #9  |  Link
onesloth
Registered User
 
Join Date: Jul 2007
Posts: 137
Quote:
Originally Posted by foxyshadis View Post
The original script simulates overlap, from before MVTools had it built in.
I figured it was something like that. 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.
onesloth is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:59.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.