Skip to content
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

VideoFrameReference should have an extension constructor for seconds= #7822

Closed
jleibs opened this issue Oct 17, 2024 · 2 comments · Fixed by #7833
Closed

VideoFrameReference should have an extension constructor for seconds= #7822

jleibs opened this issue Oct 17, 2024 · 2 comments · Fixed by #7833
Assignees
Labels
enhancement New feature or request 🐍 Python API Python logging API 🎞️ video

Comments

@jleibs
Copy link
Member

jleibs commented Oct 17, 2024

The default signature doesn't make it clear:

class VideoFrameReference(
    timestamp: VideoTimestampLike,
    *,
    video_reference: EntityPathLike | None = None
)

Create a new instance of the VideoFrameReference archetype.

Parameters
timestamp
References the closest video frame to this timestamp.

Note that this uses the closest video frame instead of the latest at this timestamp in order to be more forgiving of rounding errors for inprecise timestamp types.

I would recommend we disallow casting from int on VideoTimestampLike and add optional kwargs such as:

VideoFrameReference(seconds=12.4)
VideoFrameReference(nanos=124000000)
@jleibs jleibs added enhancement New feature or request 🐍 Python API Python logging API labels Oct 17, 2024
@jleibs jleibs added this to the Next patch release milestone Oct 17, 2024
@Wumpf Wumpf self-assigned this Oct 18, 2024
@Wumpf
Copy link
Member

Wumpf commented Oct 18, 2024

The constructor of VideoTimestamp already does the right thing:

    def __init__(
        self: Any,
        *,
        nanoseconds: Union[int, None] = None,
        seconds: Union[float, None] = None,
    ):

However, VideoTimestampLike is defined as VideoTimestampLike = Union[VideoTimestamp, int].
I think thius makes sense for VideoTimestampArrayLike because we want integer arrays to be easily convertible to timestamps (think send_columns!).
I'd rather not make this asymmetrical. Also, tightening the type is sort-of a breaking change, thus shouldn't go into a patch..?

@jleibs
Copy link
Member Author

jleibs commented Oct 18, 2024

I think the issue is that for people working with video seconds is way more common than nanoseconds.

Accidentally just doing VideoFrameReferance(timestamp=1.0) is an annoying footgun.

At a minimum that should produce an error for floats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🐍 Python API Python logging API 🎞️ video
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants