I'm trying to add the argument -r MAX_FRAME_RATE
to a command if the current r_frame_rate
is above the given MAX_FRAME_RATE
. But I'm getting an error when converting the frame rate into a float:
def push_change_frame_rate_args_to_command(self, cmd: List[str]) -> None:
if ('r_frame_rate' in self.video_metadata
and convert_str_to_float('r_frame_rate') > MAX_FRAME_RATE):
cmd.extend(["-r", str(MAX_FRAME_RATE)])
def convert_str_to_float(s: str) -> float:
"""Convert rational or decimal string to float
"""
if '/' in s:
num, denom = s.split('/')
return float(num) / float(denom)
return float(s)
File "/home/user/code/python/reduce_video_size/main.py", line 338, in convert_str_to_float
return float(s)
ValueError: could not convert string to float: 'r_frame_rate'
I'm using 'r_frame_rate': '30000/1001'
Context