This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[BUG] MvToolsFPSmod (AviSynth) - output plays too fast with wrong number of frames
#1
Bug 
Sorry to keep finding all this stuff... :\

It's amazing to me how fast you're fixing all of this... is Hybrid all you or do you have other contributors? So for what it's worth, thanks!

I tried MvToolsFPSmod for going to 60 fps. This actually looks quite promising! The problem is, in Hybrid, it outputs the wrong number of frames and the wrong duration. The whole video is processed, but plays way too fast. So the frame rate is correct, but duration and number of frames is wrong.

Here's a sample script:

ClearAutoloadDirs()
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\LoadDll.dll")
LoadCPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\ffms2.dll")
LoadPlugin("C:\PROGRA~1\Hybrid\32bit\AVISYN~1\mvtools2.dll")
LoadDLL("C:\Program Files\Hybrid\32bit\avisynthPlugins\libfftw3f-3.dll")
Import("C:\Program Files\Hybrid\32bit\avisynthPlugins\MvToolsFPSmod.avs")
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
# loading source: E:\USER\Test.mp4
#  input color sampling YV12@8, matrix:Rec.601, scantyp: progressive
#  input luminance scale tv
FFVideoSource("E:\USER\Test.mp4",colorspace="YV12")
# current resolution: 656x480
# adjusting frame rate
MvToolsFPSmod(NewNum=60000,NewDen=1001,Preset="Film")
# filtering
PreFetch(4)
return last


Here's what it outputs:

The original frame count is 4828 and the original duration is 3:13 @ 25 fps.

The correct frame count @ 59.94 fps is 11600 and the correct duration is 3:13.527, but the output frame count @ 59.94 fps is 5891 and the duration is 1:38.280.

Tried with several different videos with same results!

[Image: 0ASgpwa.png]
Reply
#2
Hmm,.. can't reproduce the issue here.
I used a source with 25fps and 429 frames.
aiming for 50/1 I get 50fps and 858 frames.
aiming for 60/1 I get 60fps and 1030 frames.
aiming for 60000/1001 I get 59.9401 fps and 1029 frames.
-> looks all fine.

Doing the calculation: 4838/25*60000/1001 ~ 11599,6 so the calculation is correct.

Is your source vfr?
Have you tried LibavSource instead of FFmpegSource?

Load your source, make your settings, set output path, enable debug output, open Avisynth Preview, disable debug output, zip/rar/7z the debug output, share the debug output with me.

Cu Selur
Reply
#3
(12.07.2020, 07:45)Selur Wrote: Doing the calculation: 4838/25*60000/1001 ~ 11599,6 so the calculation is correct.

Is your source vfr?
Have you tried LibavSource instead of FFmpegSource?

Load your source, make your settings, set output path, enable debug output, open Avisynth Preview, disable debug output, zip/rar/7z the debug output, share the debug output with me.

Cu Selur

Yes, 11600 is correct, but the output video only has 5890 frames.

Happens on an image stream as well, so don't think it's a vfr issue. Tried LibavSource and got same results.

Logs attached...

[attachment=931]
Reply
#4
The problem seems like it could be with MvToolsFPSmod.avs...

If you half the frame rate and multiply by total number of frames, you get *around* the results I'm getting: 59.94 / 2 = 29.97, 193.585 * 29.97 = 5802. I'm getting 5890 frames.

function MvToolsFPSmod(clip C, int "NewNum", int "NewDen", string "Preset")
{
Preset = Default(Preset, "Film")
P_Film = 1 P_MusicVideoClip = 2
Pset = Preset == Preset == "Film" ? P_Film : Preset == "MusicVideoClip" ? P_MusicVideoClip : P_Film
thSCD2nom= (Pset==P_Film) ? 130 : (Pset==P_MusicVideoClip) ? 255 : 130
NewNum = Default(NewNum, 60)
NewDen = Default(NewDen, 1)

FramRat = Floor(Framerate( C ))
FramRatNew = Floor(NewNum / NewDen)
NewNumN = (FramRatNew / 2 == FramRat) ? FramRatNew : FramRat*5

superfilt = MSuper(C, hpad=8, vpad=8, pel=4, sharp=2, rfilter=4)
bak = MAnalyse(superfilt, isb=true, blksize=16, blksizev=16, badSAD=1000, badrange=-3, overlap=0, overlapv=0, search=4, searchparam=0, dct=5)
fwd = MAnalyse(superfilt, isb=false, blksize=16, blksizev=16, badSAD=1000, badrange=-3, overlap=0, overlapv=0, search=4, searchparam=0, dct=5)
Flow = MFlowFps(C, superfilt, bak, fwd, num=NewNum, den=NewDen, blend=False, ml=5800, mask=0, thSCD2=thSCD2nom)

H = (FramRatNew / 2 == FramRat) ? Flow : Flow.AssumeFPS(FramRatNew * 2 , 1)
B = (FramRatNew / 2 == FramRat) ? H : H.ChangeFPS(NewNum, NewDen)

return B
}

The "FramRatNew / 2" lines are halving the frame rate.

If I change the end of the third to last line to Flow.AssumeFPS(FramRatNew * 2 , 2), then I get an output of 11782 frames, which is a bit higher than the correct 11600. This would add over 3 seconds to the length and cause the audio to go out of synch.

Of course I have no idea what I'm doing or how to correct the script.. I'm just pointing out where the problem might be, i.e. tinkering. Tongue
Reply
#5
Changing it to:
H = (FramRatNew / 2 == FramRat) ? Flow : Flow.AssumeFPS(FramRatNew)
should be correct.

Cu Selur
Reply
#6
(12.07.2020, 07:45)Selur Wrote: Hmm,.. can't reproduce the issue here.
I used a source with 25fps and 429 frames.
aiming for 60000/1001 I get 59.9401 fps and 1029 frames.
-> looks all fine.

I also get this with my image stream, if I select 429 frames at a 25 fps frame rate.

You should be able to reproduce the problem if you load a longer video source. Again, my source is 4838 frames @ 25 fps.
Reply
#7
Adjusting the script should fix the issue.

Cu Selur
Reply
#8
I tried it, but as before, the output is now 11782 frames (should be 11600 frames for 59.94 fps), which adds 3.04 seconds to the original length... the audio will go out of synch. This is only for a three minute video so it gets worse with longer videos.

Not sure if this is something that can be fixed in the script or if it's just the way MvToolsFPSmod is.

Trying an encode now... it was looking better than both Interframe and FrameRateConverter with the video speed increased! Undecided
Reply
#9
Hmm,... I'll look at it.
Reply
#10
try:
function MvToolsFPSmod(clip C, int "NewNum", int "NewDen", string "Preset")
{
    Preset = Default(Preset, "Film")
    P_Film = 1 P_MusicVideoClip = 2
    Pset = Preset == Preset == "Film" ? P_Film : Preset == "MusicVideoClip" ? P_MusicVideoClip : P_Film
    thSCD2nom= (Pset==P_Film) ? 130 : (Pset==P_MusicVideoClip) ? 255 : 130
    NewNum = Default(NewNum, 60)
    NewDen = Default(NewDen, 1)
    
    FramRat = Floor(Framerate( C ))
    FramRatNew = Floor(NewNum / NewDen)
    NewNumN = (FramRatNew / 2 == FramRat) ? FramRatNew : FramRat*5

    superfilt = MSuper(C, hpad=8, vpad=8, pel=4, sharp=2, rfilter=4)
    bak = MAnalyse(superfilt, isb=true, blksize=16, blksizev=16, badSAD=1000, badrange=-3, overlap=0, overlapv=0, search=4, searchparam=0, dct=5)
    fwd = MAnalyse(superfilt, isb=false, blksize=16, blksizev=16, badSAD=1000, badrange=-3, overlap=0, overlapv=0, search=4, searchparam=0, dct=5)
    Flow = MFlowFps(C, superfilt, bak, fwd, num=NewNum, den=NewDen, blend=False, ml=5800, mask=0, thSCD2=thSCD2nom)

    return Flow
}

Cu Selur
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)