-
When I set the rate as an integer, its working fine, but I get errors when trying to use a float or a fraction.
So what is the correct way to specify framerates like 23.976 or 29.97? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I encountered the same problem. In the case of my software, users input float value as FPS, so I defined some known FPS to avoid OverflowError. In other cases, limit the int value. def convert_known_fps(fps):
if isinstance(fps, float):
if fps == 29.97:
return Fraction(30000, 1001)
elif fps == 23.976:
return Fraction(24000, 1001)
elif fps == 59.94:
return Fraction(60000, 1001)
else:
fps_frac = Fraction(fps)
fps_frac = fps_frac.limit_denominator(0x7fffffff)
# if fps_frac.denominator > 0x7fffffff or fps_frac.numerator > 0x7fffffff:
# raise ValueError(f"FPS={fps} could not be converted to Fraction={fps_frac}")
return fps_frac
return fps If anyone knows a better method, I'd like to know. |
Beta Was this translation helpful? Give feedback.
-
Ah, guess I was staring at the code for too long to notice such an obvious mistake. I was thinking of taking the same route and just hardcoding in a few standard rates. |
Beta Was this translation helpful? Give feedback.
Fraction(24000, 1001)
works.I encountered the same problem. In the case of my software, users input float value as FPS, so I defined some known FPS to avoid OverflowError. In other cases, limit the int value.