View Full Version : Simple question about IF statement
Delerue
28th June 2010, 18:07
Hi, folks. I want to use MVFlowFPS (MVTools2) only if the video FPS is less than 35. I've tried this without success:
if( FramerateNumerator(source) > 35 )? goto end : [myscript] (the last line was 'end:')
Avisynth returns: there's no function called 'if'. I've also tried a lot of different approaches (creating a function, removing the 'goto' command, etc.), but none of them seem to work. Any ideas?
Edit: FramerateNumerator function returns the original FPS of the video, not the current FPS, right? I'm asking this because I want to use MVFlowFPS only if the current FPS is less than 35. Yadif with double framerate option checked will render two times the original video FPS, and this can make the idea of my script doesn't work.
Thanks!
Gavino
28th June 2010, 18:36
Firstly, FrameRateNumerator is not in general the framerate of anything. Frame rates are represented as a ratio of two integers, numerator and denominator. For 25fps, the denominator is 1 but, for example, for NTSC the ratio is 30000/1001 giving the well-known 29.97fps. So the number you want to check is FrameRate(source).
http://avisynth.org/mediawiki/Clip_properties
Secondly, there is no 'goto' in Avisynth.
The normal conditional is based on C syntax and looks like:
FrameRate(source) > 35 ? SomeFilter() : SomeOtherFilter()
http://avisynth.org/mediawiki/Operators
There is an extension to Avisynth called GScript which provides more powerful control structures, but the simple conditional is usually enough, unless you are writing a general function of some kind.
Delerue
28th June 2010, 19:24
Thanks, Gavino. I still have two questions.
1- if the FPS is bigger than 35 I don't want to do anything (i.e. I don't have a function to call). What you suggest to put in the first part of the IF?
2- what you suggest to detect an interlaced video or current FPS (after Yadif double framerate filter)?
Gavino
28th June 2010, 19:49
1- if the FPS is bigger than 35 I don't want to do anything (i.e. I don't have a function to call). What you suggest to put in the first part of the IF?
The NOP() function can effectively be used as a 'do nothing' operator.
2- what you suggest to detect an interlaced video or current FPS (after Yadif double framerate filter)?
If you want to base your decision on the original framerate, just save its value in a variable before doing anything that might change the rate, eg
source = AVISource(...)
rate = FrameRate(source)
... # apply filters, eg Yadif
rate > 35 ? NOP() : DoSomething()
Delerue
28th June 2010, 21:39
Hmmm... I'm using the x64 AviSynth version ported by JoshyD. I don't know if it there's anything to do, but NOP() function doesn't seem to work here when I play a video with more than 35 FPS:
FrameRate(source) > 35 ? NOP() : doubleFPS()
(I put my script inside this function called 'doubleFPS()')
AviSynth returns 'invalid script!' message every time I load a video with more than 35 FPS.
About the Yadif thing, the problem is that I'm not using the AviSynth Yadif, but the FFDShow one. Even if 'Deinterlacing' filter is put before AviSynth tab, FrameRate() function can't read the actual current FPS, but only the original.
Gavino
28th June 2010, 23:04
I don't know if it there's anything to do, but NOP() function doesn't seem to work here when I play a video with more than 35 FPS:
FrameRate(source) > 35 ? NOP() : doubleFPS()
If that's the last line of your script, you need to add another line:
return last
Alternatively, just replace NOP() by 'last' here.
About the Yadif thing, the problem is that I'm not using the AviSynth Yadif, but the FFDShow one. Even if 'Deinterlacing' filter is put before AviSynth tab, FrameRate() function can't read the actual current FPS, but only the original.
That's surprising, but a quick test confirms you are right.
Perhaps a ffdshow expert can comment further.
Delerue
29th June 2010, 04:27
Hmmm! I've figured out that using 'source' this way resolves the first problem:
FrameRate(source) > 35 ? source : doubleFPS()
About the reading of current FPS, I think you're right. Another approach could be retrieving the interlacing flag from the video. But I read here (http://avisynth.org/mediawiki/Interlaced_fieldbased) that AviSynth doesn't have it anymore. :(
Thanks, man.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.