-
Notifications
You must be signed in to change notification settings - Fork 474
Closed
Description
Hi !
Thank you for PySceneDetect.
I ran into issues where after some serialization the resulting time frame was not the expected one.
For example:
frame_time_code = FrameTimecode(61, fps=14)
seconds = frame_time_code.get_seconds()
time_code = frame_time_code.get_timecode()
...
FrameTimecode(seconds, fps=14).get_frames() == 60 # not 61
FrameTimecode(time_code, fps=14).get_frames() == 60 # not 61I found the corresponding code with flooring (with int instead of round) :
PySceneDetect/scenedetect/frame_timecode.py
Lines 227 to 236 in f6c61dd
| def _seconds_to_frames(self, seconds): | |
| # type: (float) -> int | |
| """ Converts the passed value seconds to the nearest number of frames using | |
| the current FrameTimecode object's FPS (self.framerate). | |
| Returns: | |
| Integer number of frames the passed number of seconds represents using | |
| the current FrameTimecode's framerate property. | |
| """ | |
| return int(seconds * self.framerate) |
PySceneDetect/scenedetect/frame_timecode.py
Line 307 in f6c61dd
| return int(secs * self.framerate) |
I ran into the following code which seems to indicate this is on purpose. What is the reason?
PySceneDetect/tests/test_frame_timecode.py
Lines 114 to 116 in f6c61dd
| assert FrameTimecode(timecode='00:00:01', fps=1).frame_num == 1 | |
| assert FrameTimecode(timecode='00:00:01.9999', fps=1).frame_num == 1 | |
| assert FrameTimecode(timecode='00:00:02.0000', fps=1).frame_num == 2 |
Have a nice day !