-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with sv.VideoInfo FPS Handling for Precise Video Metadata Retrieval #1687
Comments
Hi @joesu-angible 👋 Thank you for reporting the issue! Indeed, half of our own asset videos don't have a round number for the fps. Test codeimport supervision as sv
from supervision.assets import VideoAssets, download_assets
import cv2
# int fps: People walking, Market square, Skiing, Milk bottling plant, Vehicles
# float fps: Subway, Basketball, Grocery Store, Beach, Vehicles 2
asset = VideoAssets.VEHICLES_2
download_assets(asset)
video = cv2.VideoCapture(asset.value)
fps = video.get(cv2.CAP_PROP_FPS)
print(fps, type(fps))
video_info = sv.VideoInfo.from_video_path(asset.value)
print(video_info) This would be a superb PR submission! However, since we've had the
Does that sound interesting, @joesu-angible? |
@LinasKo I have been testing this. I ran the sample code for While the output videos are visually the same, there are minor differences in some parameters. ![]() ![]() ![]() |
Hi @miteshashar thanks for running the tests. I think the most noticeable difference shouldn't be in the file size but in the video length. Did you take such measurements as well? |
Hi @SkalskiP, I did some refactoring over yesterday and today and have finished running tests for [coreml/cpu] X [float/int] X [video_sink/byte_track]. I will further work around getting the durations. That should not be too much of a mod. I am expecting to get back with these by tomorrow. |
@SkalskiP So, there is a difference in the duration. Obtained using ![]() |
Below are updates based on all the tests I have run until now.
The following tests now remain.
|
Search before asking
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))
tofps = float(video.get(cv2.CAP_PROP_FPS))
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: