1. Or duplicate a frame to create one where one was missing and then replace it with a new and interpolated one:

Loop(2,1325,1325)
RX(1326,1)

Here you've created a new frame number 1326 to temporarily 'stand in' for the missing frame (by duplicating #1325) and then interpolated off of the frames on either side. That way the function doesn't have to be modified. Of course you can create as many new duplicate frames as is necessary and then replace them all with interpolated ones.

Me, I find the function descriptive and easy enough to understand with its given name, not to mention much quicker to type when necessary (I'm a lousy typist). I'm assuming 'RP' means 'Replace Pairs' and 'RX' means 'Replace X Number Of Frames'. Searching? Yes, that's a different matter.
2. Here's my mod of RX() to insert missing farmes rather than replace existing frames. Audio is blank during the inserted frames.

Code:
```function InsertFramesMC(clip Source, int N, int X)
{
# inserts missing frames using motion interpolation
# N is the frame number before which the sequence will be inserted
# X is number of frames to insert
# the video length is increased by X frames
# won't work for N=0, N>last
#
# e.g. InsertFramesMC(101, 5) would
# keep the source's frames from 0 to 100
# create and insert 5 motion interpolated frames (based on source frames 100 and 101)
# append the source's frames 101 to the end
# audio is silent during the inserted frames

start=Source.trim(N-1,-1) # frame before N, used for interpolation starting point
end=Source.trim(N,-1) # frame at N, used for interpolation ending point
start+end # join them into a two frame video
AssumeFPS(1) # temporarily FPS=1 to use mflowfps

super = MSuper()
backward_vec = MAnalyse(super, isb = true)
forward_vec = MAnalyse(super, isb = false)
MFlowFps(super, backward_vec, forward_vec, blend=false, num=(X+1), den=1)
Trim(1, X) # trim ends, leaving only the frames for insertion

Source.trim(0,-N) ++ last ++ Source.trim(N,0) # join, before, inserted, after
}```
Or using manono's "loop" method and the original RX():

Code:
```function InsertFramesMC(clip Source, int N, int X)
{
loop(Source, X+1, N, N)
RX(N, X)
}```
Maybe you'll want to call it IX()?

My first thought was to insert blank or repeat frames and use RX but I didn't know what function could do that. Manono's method has the additional benefit that it won't require modification if RX() is improved in the future.
3. Thanks, jagabo. I'll give that a try and report back.
4. Here's a version of ReplaceFramesMC() that works a little differently. I find it usually works a little better than the version posted earlier. It can be called by InsertFramesMC() too.

Code:
```function ReplaceFramesMC(clip Source, int N, int X)
{
# N is number of the 1st frame in Source that needs replacing.
# X is total number of frames to replace
#e.g. RX(101, 5) would replace 101,102,103,104,105 , by using 100 and 106 as reference points for mflowfps interpolation

start=Source.trim(N-1,-1) #one good frame before, used for interpolation reference point
end=Source.trim(N+X,-1) #one good frame after, used for interpolation reference point

start+end
AssumeFPS(1) #temporarily FPS=1 to use mflowfps

backward_1 = MAnalyse(super, chroma=false, isb=true, blksize=16, searchparam=3, plevel=0, search=3, badrange=(-24))
forward_1 = MAnalyse(super, chroma=false, isb=false, blksize=16, searchparam=3, plevel=0, search=3, badrange=(-24))
backward_2 = MRecalculate(super, chroma=false, backward_1, blksize=8, searchparam=1, search=3)
forward_2 = MRecalculate(super, chroma=false, forward_1, blksize=8, searchparam=1, search=3)
backward_3 = MRecalculate(super, chroma=false, backward_2, blksize=4, searchparam=0, search=3)
forward_3 = MRecalculate(super, chroma=false, forward_2, blksize=4, searchparam=0, search=3)
MBlockFps(super, backward_3, forward_3, num=X+1, den=1, mode=0)

AssumeFPS(FrameRate(Source)) #return back to normal source framerate for joining
Trim(1, framecount-1) #trim ends, leaving replacement frames

Source.trim(0,-N) ++ last ++ Source.trim(N+X+1,0)
}```
5. Jagabo, I've tried the first version of your function, and it works very well for my purposes. Thank you very much. I'll have a look at your second function too.

It can be called by InsertFramesMC() too.
How is this accomplished? I still don't understand how functions work: I just use them.
6. Originally Posted by Jeff B
It can be called by InsertFramesMC() too.
How is this accomplished? I still don't understand how functions work: I just use them.
The argument syntax is identical to RX(). So you can get rid of the old RX() and rename the new function RX(). Or you could modify the call in InsertFramesMC() to call this function instead.

For example, if you kept the old version named RX(), and added my new version called ReplaceFramesMC(), then you could modify the "RX(N, X)" line in InsertFramesMC() to read "ReplaceFramesMC(N, X)".

Or you could keep both pairs of functions:

Code:
```function RX(clip Source, int N, int X)
{
# N is number of the 1st frame in Source that needs replacing.
# X is total number of frames to replace
#e.g. RX(101, 5) would replace 101,102,103,104,105 , by using 100 and 106 as reference points for mflowfps interpolation

start=Source.trim(N-1,-1) #one good frame before, used for interpolation reference point
end=Source.trim(N+X,-1) #one good frame after, used for interpolation reference point

start+end
AssumeFPS(1) #temporarily FPS=1 to use mflowfps

super = MSuper()
backward_vec = MAnalyse(super, isb = true)
forward_vec = MAnalyse(super, isb = false)
MFlowFps(super, backward_vec, forward_vec, blend=false, num=X+1, den=1) #num=X+1
AssumeFPS(FrameRate(Source)) #return back to normal source framerate for joining
Trim(1, framecount-1) #trim ends, leaving replacement frames

Source.trim(0,-N) ++ last ++ Source.trim(N+X+1,0)
}

function IX(clip Source, int N, int X)
{
loop(Source, X+1, N, N)
RX(N, X)
}```
and:

Code:
```function ReplaceFramesMC(clip Source, int N, int X)
{
# Replace X frames, starting at N, with motion interpolated frames
# N is number of the 1st frame in Source that needs replacing.
# X is total number of frames to replace
#e.g. RX(101, 5) would replace 101,102,103,104,105 , by using 100 and 106 as reference points for mflowfps interpolation

start=Source.trim(N-1,-1) #one good frame before, used for interpolation reference point
end=Source.trim(N+X,-1) #one good frame after, used for interpolation reference point

start+end
AssumeFPS(1) #temporarily FPS=1 to use mflowfps

backward_1 = MAnalyse(super, chroma=false, isb=true, blksize=16, searchparam=3, plevel=0, search=3, badrange=(-24))
forward_1 = MAnalyse(super, chroma=false, isb=false, blksize=16, searchparam=3, plevel=0, search=3, badrange=(-24))
backward_2 = MRecalculate(super, chroma=false, backward_1, blksize=8, searchparam=1, search=3)
forward_2 = MRecalculate(super, chroma=false, forward_1, blksize=8, searchparam=1, search=3)
backward_3 = MRecalculate(super, chroma=false, backward_2, blksize=4, searchparam=0, search=3)
forward_3 = MRecalculate(super, chroma=false, forward_2, blksize=4, searchparam=0, search=3)
MBlockFps(super, backward_3, forward_3, num=X+1, den=1, mode=0)

AssumeFPS(FrameRate(Source)) #return back to normal source framerate for joining
Trim(1, framecount-1) #trim ends, leaving replacement frames

Source.trim(0,-N) ++ last ++ Source.trim(N+X+1,0)
}

function InsertFramesMC(clip Source, int N, int X)
{
# Insert X motion interpolated frames at N
# N is the insertion point
# X is the number of frames to insert
# the frames will be interpolated with Source frames N-1 and N as references

loop(Source, X+1, N, N)
ReplaceFramesMC(N, X)
}```
7. Jagabo, does InsertFramesMC use a great deal of memory? When I try to render from Virtualdub, it hangs. I have just received an error message.

Avisynth read error("GetFrameBuffer: Returned a VFB with a 0 data pointer!\n"
"size=3110464, max=536870912, used=86540224"
"I think we have run out of memory folks!"
I guess this has something to do with MVTools. Does anyone have ideas?

EDIT: I've just tried using SetMemoryMax.

SetMemoryMax(64)

It seems to be rendering all right.
8. i am working on script (on another language) that can create a full mapfile.txt/map data within a few seconds for the RemapFrames() function.

I will share it when I will done..
9. Originally Posted by Jeff B
Jagabo, does InsertFramesMC use a great deal of memory?
I'm not really sure. I've only used it on short videos. I seem to recall having problems with ReplaceFramesMC() when the number of frames got over ~15. I don't remember exactly what the problem was but it might be related.
10. I've used InsertFramesMC dozens of times within a single AviSynth script and with it interpolating frames into the 20's at a time and haven't had any problems.

And thanks for that script, jagabo. It doesn't work miracles but it gets rid of those weird white edge artifacts and is a distinct improvement over the earlier interpolators.
11. Originally Posted by manono
And thanks for that script, jagabo. It doesn't work miracles but it gets rid of those weird white edge artifacts and is a distinct improvement over the earlier interpolators.
Glad it helped you out. I just took the code from another frame rate interpolator and adapted it.
12. Originally Posted by jagabo
I'm not really sure. I've only used it on short videos. I seem to recall having problems with ReplaceFramesMC() when the number of frames got over ~15. I don't remember exactly what the problem was but it might be related.
Originally Posted by manono
I've used InsertFramesMC dozens of times within a single AviSynth script and with it interpolating frames into the 20's at a time and haven't had any problems.
Thank you both for the information. I think the problem is with MVTools rather than the function. I found an old thread here, in which this is discussed on this and the following page. Regardless, adding SetMemoryMax() seemed to work.

Statistics