AcademySoftwareFoundation / AcademySoftwareFoundation/OpenTimelineIO
RationalTime value mismatch when serialize/deserialize to JSON
- Dominant language
- C++
- Stars
- 2k
- Forks
- 351
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 1
Description
# Required:
------------
* [X] I believe this isn't a duplicate topic
* [X] This report is not related to an adapter
For adapter related issues, please go to the appropriate repository - likely in
the [OpenTimelineIO github organization](https://github.com/OpenTimelineIO/).
For general questions and help please use the
[Academy Software Foundation slack](https://slack.aswf.io/),
[#opentimelineio](https://academysoftwarefdn.slack.com/messages/CMQ9J4BQC).
## Select One:
* [ ] Build problem
* [X] Incorrect Functionality or bug
* [ ] New feature or functionality
## Description
I'm having RationalTime accuracy issue when serializing/deserializing a `Clip` as `json`.
It's very small but enough to produce value comparison mismatch on my end.
Is that expected ? Has anyone spotted that before ?
Is there something else I do not understand ?
(tested with `opentimelineio-0.17.0 `)
## Reproduction Steps
```python
import opentimelineio as otio
rate_23_976 = 23.976024627685547
# Create a random clip
start = otio.opentime.RationalTime(30, 24.0)
src_range = otio.opentime.TimeRange(
start.rescaled_to(rate_23_976),
otio.opentime.RationalTime(0, rate_23_976)
)
clip = otio.schema.Clip(name="test", source_range=src_range)
# Recreate same clip through serialization/deserialization to JSON
clip2 = otio.schema.Clip.from_json_string(clip.to_json_string())
# Comparison
assert clip2.source_range.start_time == clip.source_range.start_time # I'm expecting this to be True but raises
assert clip.source_range.start_time.rate == clip2.source_range.start_time.rate # OK
assert clip.source_range.start_time.value == clip2.source_range.start_time.value # raises
```
Contributor guide
Research direction
Start with the provided Python reproduction using Clip.to_json_string() and Clip.from_json_string(), then inspect how RationalTime values and rates are serialized and restored. Confirm the behavior with the equality assertions; done means the round trip preserves the expected RationalTime value or clearly documents the intended comparison behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100