-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add support for v1 timestamps file #10
base: main
Are you sure you want to change the base?
Conversation
The previous algorithm supposed that first_timestamps was created from pts/time_scale, so it was always a multiple of time_scale. But, even if it is generally the case, it isn't for v1 timestamps file. In [this example](https://github.com/moi15moi/VideoTimestamps/blob/f9f1b64ef0c0f9e0f2b84210d325fc4080e57101/tests/test_text_file_timestamps.py#L9-L38), when we get over the frame 11, we need to calculate the time from the last frame pts. Since the time_scale is 1000, the last frame pts is 567, but that pts is rounded. In reality, the last pts is 1700/3 = 566.666 (pts are never float, but that's just to show that it is slightly rounded). Since we use the last frame pts to create a FPSTimestamps object, there is some rounding error since we start at the pts 567. The solution for this is to use the last frame timestamps which is (1700/3)/1000 second as our first_timestamps to create a FPSTimestamps object. But, (1700/3)/1000 isn't a multiple of time_scale (1000), we need to use a new formula that include the first_timestamps when it round or floor.
There isn't any reason to keep it since it isn't used anywhere.
This allow us to use the new doc algorithm (Algorithm conversion explanation.md). Also, update the test to use the new API.
…e_pts_from_last_timestamps
…last_timestamps The approximate_pts_from_last_timestamps was a hack that didn't always work. With last_timestamps, there isn't any hack and if the user provide the right value, it's perfect in term of precision.
As says in the commit b0403f436dd9251e61772600fe3169f508307aa1, the user needs to provide ``last_timestamps`` when they need precise results while requesting a frame or timestamp over the video duration.
6af8407
to
2d60264
Compare
We need this because, for FPSTimestamps, the first_timestamps provided by the user may not be the product of first_timestamps and time_scale may not produce a integer. As a reminder, timestamps = pts / time_scale.
The new constructor of VideoTimestamps can use the last_timestamps (non-rounded), so we don't need this parameter anymore
2d60264
to
278da8b
Compare
278da8b
to
4a116a4
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
==========================================
- Coverage 97.87% 97.31% -0.56%
==========================================
Files 16 16
Lines 1364 1492 +128
==========================================
+ Hits 1335 1452 +117
- Misses 29 40 +11 ☔ View full report in Codecov by Sentry. |
Fix #6