View Full Version : Using ffvideosource to set fractional framerate
TCmullet
4th September 2019, 00:31
I have a need to set ffvideosource to a fractional framerate. Usually it's
fpsnum=60000,fpsden=1001
to get 59.94. But I need to have 58.756 fps. (An unusual situation.) Yet fpsnum accepts only integers. Any thoughts on how to do this?
(And I may need to do 58.758 as well.)
If this cannot be done, then I'll be forced to use 59.94 and do a stretch on the audio, which is always a real pain.
StainlessS
4th September 2019, 00:52
test 1
BlankClip(fps=60000, fps_denominator=1001)
#Info
newrate=58.756 # Oops was wrong
#newrate=58.758
AssumeFPS(NewRate)
#Info
FpsNum = FrameRateNumerator
FpsDen = FrameRateDenominator
test 2
newrate=58.756 # Oops was wrong
#newrate=58.758
FpsNum = Round(newrate * 1000.0)
FpsDen = 1000
Neither one tested.
EDIT: I think that the 1st one may try to coerce numbers to NTSC standard numbers if very close to those [above newrate numbers will not be 'close enough'].
johnmeyer
4th September 2019, 01:00
Any reason you can't use:
num = 58756
den = 1000
Unlike the 1000/1001 NTSC multiplier, this one will give you exactly 58.756, without any additional over- or underage beyond the third decimal place.
StainlessS
4th September 2019, 01:14
Nothing stopping you doing that, but the given code does not assume that you already know the input numbers. [ie you did the math for it]
EDIT: Also this would work just fine
FpsNum = Round(newrate * 1000) # works whether newrate is float or int, but you aint saving much at all
FpsDen = 1000
EDIT: Or even
FpsDen = 1000 # but this really should be int, or fail in FFVideoSource
FpsNum = Round(newrate * FpsDen)
TCmullet
4th September 2019, 01:14
Any reason you can't use:
num = 58756
den = 1000
Unlike the 1000/1001 NTSC multiplier, this one will give you exactly 58.756, without any additional over- or underage beyond the third decimal place.
Ha, ha, ha! No! I was too dense to realize that! Thanks!
(But further tests since I posted point toward the likelihood I'll have to do the 59.94-and-audio-stretch route. But will try this simple thing!)
StainlessS
4th September 2019, 01:32
FpsNum = Round(newrate * 1000) # works whether newrate is float or int, but you aint saving much at all
FpsDen = 1000
Actually, above MAY be slower than using float 1000.0 [although not really worth any mention], because the 1000 Integer will then be converted to float prior to the multiply of newrate.
[if float +,-,*,/ by int, then int is implicitly converted to float beforehand. EDIT: Same if int * float etc]
EDIT:
and if newrate is eg int 25, then will be equivalent to
FpsNum = Round(Float(25 * 1000))
is equivalent to
FpsNum = int(Float(25 * 1000) + 0.5)
EDIT: Some Didee code assumes that result of Round() is whole number type float, but is actually type Int.
Not sure, but think some/all versions of the [I think] m4() function do something like Int(Round(...)) where the Int() part is superfluous.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.