Log in

View Full Version : My mvtools2 script for Slo Motion


Jeremy Duncan
1st August 2009, 11:30
It's used on a ntsc dvd that has pulldown as it's still on the disk. I'm using ffdshow to use thisin realtime, and no I max out my cpu so I can't say which cpu would do it flawlessly.


Last=ffdshow_source()
bob
setmemorymax(610)
MT("""
super = MSuper(pel=2,hpad=4,vpad=4)
backward_vec = MAnalyse(super,chroma=false, blksize=16, isb = true, search=5, searchparam=1)
forward_vec = MAnalyse(super, chroma=false, blksize=16)
MFlowFps(super, backward_vec, forward_vec, num=0, mask=1, ml=49)
super = MSuper(pel=2,hpad=4,vpad=4)
backward_vec = MAnalyse(super,chroma=false, blksize=16, isb = true, search=5, searchparam=1)
forward_vec = MAnalyse(super, chroma=false, blksize=16)
MFlowFps(super, backward_vec, forward_vec, num=3500, \
den=100, mask=1, ml=49)
""",2)


Tings you can do to tweak it for yourself:
a.) choose a better bobber.
b.) change the num=3500 number to higher or lower to affect the speed of the slo motion.
c.) it should work for pal and ntsc the same. :)
d.) why did I post this here? I'm using mvtools2 the newest one and I thought it would be nice to do so I posted this info here.

mvtools2 homepage (http://avisynth.org.ru/mvtools/mvtools2.html)
mvtools2 dll (http://www.mediafire.com/?mywh5lcqtcg)

Gavino
1st August 2009, 14:13
I haven't tried your script, but I have a couple of questions:
- Why are you calling MFlowFPS twice? Can't you just call it once?
- You are missing a Weave() after SeparateFields.SelectEvery(4,0,3); I'm not sure why you have this anyway, but without Weave your script will produce half-height output and bob up and down.

rickard_liljeberg
1st August 2009, 14:42
Hi!

I am completely new to avisynth altho I have used virtualdub quite a bit.

I have a 5D II that is filming at 1920*1080 at 30fps in progressive.

I want it to go 4 times slower

Would you be super kind and edit your script to fit that description. I would be very grateful as I have no gotten it to work now after several hours of trying.

I just finally managed to get a squished image out, but that was as good as I got

rickard_liljeberg
1st August 2009, 16:25
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools2.dll")
Last=AVISource("MVI_2031_lagarith.avi").ComplementParity.ConvertToYUY2
super = MSuper(pel=2,hpad=4,vpad=4)
backward_vec = MAnalyse(super,chroma=false, blksize=16, isb = true, search=5, searchparam=1)
forward_vec = MAnalyse(super, chroma=false, blksize=16)
MFlowFps(super, backward_vec, forward_vec, num=60, \
den=1, mask=1, ml=49)

That seems to be working properly num=60 sets the new frames per second which in my case is twice of my 30fps.
then when importing it into virtualdubmod you can just go and set the framerate to 30fps and thus you will have slowed down the video to half

Jeremy Duncan
1st August 2009, 20:55
I haven't tried your script, but I have a couple of questions:
- Why are you calling MFlowFPS twice? Can't you just call it once?


Once to double the frame rate and the other to control the slo motion speed.
I tried with only one and I looked online for a script example and didn't find any.


I haven't tried your script, but I have a couple of questions:
- You are missing a Weave() after SeparateFields.SelectEvery(4,0,3); I'm not sure why you have this anyway, but without Weave your script will produce half-height output and bob up and down.

I tried it without separatefields and selectevery and it stopped bobbing!
I tried it with weave keeping separatefields and selectevery and it had lines in there, that's why I didn't have weave in there.

I adjusted the script in the first post to show the changes you helped me with. :)

rickard_liljeberg,

My first post shows what I used on 29.97 fps dvd's. So it should work for your stuff too since the fps difference is really small.

I don't know the Exact number for 4x slower, just change the num=3500 to a higher or lower number to adjust the speed.

Everybody,

For interlaced stuff I don't know what to change in the script? Maybe I would do that next but I like what I have and don't need to adjust for interlaced so I will leave the first post as it is. :)

Gavino
1st August 2009, 22:36
[I previously asked why call MFlowFPS twice]
Once to double the frame rate and the other to control the slo motion speed.
I tried with only one and I looked online for a script example and didn't find any.
But why double it first if you're going to change it again anyway?
rickard_liljeberg's example has shown this is unnecessary.
I don't know the Exact number for 4x slower, just change the num=3500 to a higher or lower number to adjust the speed.
rickard has explained what the numbers mean, and this is also explained in the MVTools docs.
num=60 sets the new frames per second which in my case is twice of my 30fps.
then when importing it into virtualdubmod you can just go and set the framerate to 30fps and thus you will have slowed down the video to half
You can achieve this more simply by adding AssumeFPS(30) at the end of your script.
BTW I thought you wanted 4x, which would be num=120.

Jeremy Duncan
2nd August 2009, 01:04
gavino,

I assume you mean that this is the script I should use instead of the one in the first post:

setmtmode(5)
Last=ffdshow_source()
setmtmode(2)
super = MSuper(pel=2,hpad=8,vpad=4)
backward_vec = MAnalyse(super,chroma=false, blksize=16, isb = true, search=5, searchparam=1)
forward_vec = MAnalyse(super, chroma=false, blksize=16)
MFlowFps(super, backward_vec, forward_vec, num=0, mask=1, ml=49)
#Also tried assumefps here
distributor()
AssumeFPS(2997)

It does nothing to add slo motion. I already tried this.

And I know the way num works with den. Both = last, num and den work together using division in such a fashion the fps is altered.
The reason I said I didn't know 4x slower exactly was based on the code in the first post and not the mvtools2 readme showing the functions.

Why use 2 instances of mvtools2? Because it works.
If you can get it working using prettier code then please show how. :)

rickard_liljeberg
2nd August 2009, 03:47
[I previously asked why call MFlowFPS twice]

But why double it first if you're going to change it again anyway?
rickard_liljeberg's example has shown this is unnecessary.

rickard has explained what the numbers mean, and this is also explained in the MVTools docs.

You can achieve this more simply by adding AssumeFPS(30) at the end of your script.
BTW I thought you wanted 4x, which would be num=120.

Yes I did want 4x but only got it to look good at 2x.
The script is otherwise working beaitifully.

assumefps sounds smart, I'll add that.

Other than that I am right now tweaking settings. I managed to get rid of choppy motion at slower than 2x (which was the problem) but instead I got some ugly frames that had what looked like compression artefacts.

So from now on I am simply going to use my script above, add assumefps and then by trial and error se what makes it better and worse for over 2x.

shoopdabloop
2nd August 2009, 03:56
quick question for anybody, when we are asked to provide a num and den, is it safe to use a den of 1?

Jeremy Duncan
2nd August 2009, 04:14
I got some ugly frames that had what looked like compression artefacts

That's the hpad setting. I forgot to put it to 8 in the first post and just did so.

hpad=4 gives more artifacts then hpad=8.

If num =29.970 fps, then num=2997. den=1 in this case leaves the fps 29.970 fps. den=2 divides the 29.970fps by 2.

Keiyakusha
2nd August 2009, 04:16
quick question for anybody, when we are asked to provide a num and den, is it safe to use a den of 1?
Any value is safe, as long as it's fits your needs.

Gavino
2nd August 2009, 10:12
I assume you mean that this is the script I should use instead of the one in the first post
No, I meant you should remove the first (rate-doubling) chunk of code and keep the second, not the other way round.
AssumeFPS(2997)
This should be AssumeFPS(29.97), or better, AssumeFPS(30000, 1001)
Why use 2 instances of mvtools2? Because it works.
If you can get it working using prettier code then please show how. :)
rickard_liljeberg already showed how.

@shoopdabloop : use den=1 when the frame rate you want is an exact integer.

Jeremy Duncan
8th August 2009, 02:39
I updated the first post with a more stable script.

Here is a quote from Leak:

Except that AssumeFPS plain doesn't work in ffdshow. I made sure of that, as no matter what you it'll destroy any synchonization between audio and video since AviSynth only operates on the audio.

AssumeFPS all you want - ffdshow will use the timestamps of the input frames to calculate the output frame timestamps. If your file itself has it's framerate wrong remux it with the correct framerate.

np: Fink - If Only (Distance And Time)

link (http://forum.doom9.org/showthread.php?p=1261495#post1261495)

So using assumefps isn't gonna work in my situation. :)

Gavino
9th August 2009, 13:30
So using assumefps isn't gonna work in my situation. :)
If I understand correctly (after looking into the background behind leak's statement), there is no way at all to do a 'slow motion' script within ffdshow's avisynth filter, because it never changes the video duration. The reason you thought you were getting slow motion was probably just that your script was too slow to render in real time.

Of course, outside of ffdshow it is no problem at all (as shown for example by rickard_liljeberg in this thread).

Jeremy Duncan
9th August 2009, 19:36
Last=ffdshow_source()
bob
setmemorymax(610)
MT("""
super = MSuper(pel=2,hpad=4,vpad=4)
backward_vec = MAnalyse(super,chroma=false, blksize=16, isb = true, search=5, searchparam=1)
forward_vec = MAnalyse(super, chroma=false, blksize=16)
MFlowFps(super, backward_vec, forward_vec, num=0, mask=1, ml=49)
super = MSuper(pel=2,hpad=4,vpad=4)
backward_vec = MAnalyse(super,chroma=false, blksize=16, isb = true, search=5, searchparam=1)
forward_vec = MAnalyse(super, chroma=false, blksize=16)
MFlowFps(super, backward_vec, forward_vec, num=1000, \
den=100, mask=1, ml=49)
""",2)

This code compared to the one in the first post.
It's more choppy, not fluid. The motion changes depending on how I set Num in the second mflowfps.

Gavino
9th August 2009, 20:44
It's more choppy, not fluid. The motion changes depending on how I set Num in the second mflowfps.
It's more choppy because it has a frame rate of 10fps (1000/100), while in your first post you have 35fps.
But in both cases the scripts should have exactly the same duration as the original clip, so any 'slow motion' is due to being unable to play in real time. (You say in the first post your cpu is maxed out.)

Or maybe you mean something else by 'slow motion'?

Jeremy Duncan
10th August 2009, 01:33
the scripts should have exactly the same duration as the original clip

I had to make a test file from scratch. I got a apple trailer and made it into a ts file then played it in mpc hc.
The sliding bar that moves showing the position of the movie was the same as in the regular trailer, same speed, but when it reached the end the video kept going at the same slo mo speed at it started at.
This is using the script in the first post.

I had to resize the 720 apple video to spline64resize(848, 352).
I could provide the sample if my internet speed was better.
One has audio the other is only video, I tested the one with only video.

Gavino
10th August 2009, 12:33
The sliding bar that moves showing the position of the movie was the same as in the regular trailer, same speed, but when it reached the end the video kept going at the same slo mo speed at it started at.
That is exactly what happens when the player cannot play a video in real time (and is not set to drop frames on delay).

So, again, I say that the slow motion is not produced by your script as such. If you encoded your script (replacing ffdshow_source by the appropriate source filter for the file), the resultant video would not exhibit slow motion.

Therefore, to present this as a 'mvtools2 script for slow motion' is misleading.
Any 'slow' script (eg MCBob()) would produce the same effect when played directly.