Issue with sv.VideoInfo FPS Handling for Precise Video Metadata Retrieval #1687
Description
Search before asking
- I have searched the Supervision issues and found no similar feature requests.
Description
Hello,
I'm using sv.VideoInfo.from_video_path
to retrieve video metadata and perform video manipulations. However, I've noticed an issue with how fps is calculated. Specifically, sv.VideoInfo.from_video_path
uses the following method:
fps = int(video.get(cv2.CAP_PROP_FPS))
This approach can lead to inaccuracies in certain scenarios. For example, if the actual FPS of a video is 24.999, the method will round this down to 24. Over a long video, this discrepancy can cause significant shifts and synchronization problems.
Would it be possible to modify the implementation to return the FPS as a float rather than truncating it to an integer? This would improve accuracy for edge cases like this.
Thank you for your attention!
Use case
Change the method of fps from fps = int(video.get(cv2.CAP_PROP_FPS))
to fps = float(video.get(cv2.CAP_PROP_FPS))
Additional
No response
Are you willing to submit a PR?
- Yes I'd like to help by submitting a PR!