@@ -154,20 +154,14 @@ def drawTime(self, img: np.ndarray, frame_num: int) -> np.ndarray:
154154 np.ndarray: opencv image with Time Text
155155 """
156156 annotated_img = img .copy ()
157- current_timestamp = FFmpegStream .millisec_to_timestamp (
158- self .frame_to_millisec (frame_num , self .video_info .fps )
159- )
157+ current_timestamp = FFmpegStream .frame_to_timestamp (frame_num , self .video_info .fps )
160158 current_timestamp = '' .join (current_timestamp [:- 4 ])
161159
162160 if self .params .end_frame < 1 :
163- end_timestamp = FFmpegStream .millisec_to_timestamp (
164- self .frame_to_millisec (self .video_info .length , self .video_info .fps )
165- )
161+ end_timestamp = FFmpegStream .frame_to_timestamp (self .video_info .length , self .video_info .fps )
166162 end_timestamp = '' .join (end_timestamp [:- 4 ])
167163 else :
168- end_timestamp = FFmpegStream .millisec_to_timestamp (
169- self .frame_to_millisec (self .params .end_frame , self .video_info .fps )
170- )
164+ end_timestamp = FFmpegStream .frame_to_timestamp (self .params .end_frame , self .video_info .fps )
171165 end_timestamp = '' .join (end_timestamp [:- 4 ])
172166
173167 txt = current_timestamp + ' / ' + end_timestamp
@@ -295,21 +289,6 @@ def calculate_score(self) -> None:
295289 self .score ['y' ] = sp .scale_signal (self .score ['y' ], 0 , 100 )
296290
297291
298- @staticmethod
299- def frame_to_millisec (frame : int , fps : float ) -> int :
300- """ Convert frame number to timestamp in video
301-
302- Args:
303- frame (int): the framenumber to convert to an timestamp
304- fps (float): Video FPS
305-
306- Returns:
307- int: the timestamp in milliseconds in video for the given framenumber
308- """
309- if frame < 0 : return 0
310- return int (round (float (frame )* float (1000 )/ fps ))
311-
312-
313292 def scale_score (self , status : str , direction : str = 'y' ) -> None :
314293 """ Scale the score to desired stroke high
315294
@@ -814,15 +793,15 @@ def run(self) -> None:
814793 min (output_score ) \
815794 if output_score [idx ] < min (output_score ) + self .params .bottom_threshold \
816795 else round (output_score [idx ]),
817- self .frame_to_millisec (self .apply_shift (idx , 'min' ), self .video_info .fps )
796+ FFmpegStream .frame_to_millisec (self .apply_shift (idx , 'min' ), self .video_info .fps )
818797 )
819798
820799 for idx in idx_dict ['max' ]:
821800 self .funscript .add_action (
822801 max (output_score ) \
823802 if output_score [idx ] > max (output_score ) - self .params .top_threshold \
824803 else round (output_score [idx ]),
825- self .frame_to_millisec (self .apply_shift (idx , 'max' ), self .video_info .fps )
804+ FFmpegStream .frame_to_millisec (self .apply_shift (idx , 'max' ), self .video_info .fps )
826805 )
827806
828807 self .finished (status , True )
0 commit comments