Skip to content

Fix snapping audio times to current video position#609

Open
arch1t3cht wants to merge 2 commits into
masterfrom
fix-snap-video-pos
Open

Fix snapping audio times to current video position#609
arch1t3cht wants to merge 2 commits into
masterfrom
fix-snap-video-pos

Conversation

@arch1t3cht

Copy link
Copy Markdown
Member

Lots of text incoming, since timestamp wrangling is hell and I want to write down my reasoning before I inevitably forget it again in two weeks.

Before commit 5d4973a, snapping an audio line's end time to the "current video position" indicator line would reliably make the line end on the frame before the current video frame (i.e. make the current video frame be the first frame where the selected line is not visible any more).

Commit 5d4973a broke this, making the behavior of snapping audio times to the "current video position" inconsistent.

The commit in question is definitely not fully correct, ultimately just because the entire concept of implicitly converting millisecond timestamps to centisecond timestamps is flawed in and of itself, and bound to always fail in sufficiently crazy edge cases. Fixing the timestamp conversion properly would entail either working with centisecond timestamps from the beginning, or somehow making the process of converting timestamps aware of the context the timestamps are from (e.g. "coming from some frame timestamp").

However, this specific issue was only exposed by this commit, and not solely caused by it. Its root cause was just that the "current video position" marker on the audio display would mark the exact time of the current video frame, rather than the ideal start/end time for a line to start/end at that video frame. This is why only snapping to the "current video position" broke while snapping to keyframes worked fine. It's quite possible that snapping to the "current video frame" marker was just never thought of as a use case.

So, for now, #421 can just be fixed by positioning the "current video position" marker in the middle of the frame rather than at the frame's exact start, and
5d4973a can be untangled at some later time.

Fixes #421.


Still need to decide how to handle the fact that keyframe markers and current frame markers may now overlap.

@petzku

petzku commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

First: This new snapping behavior itself is much better, thank you.

Still need to decide how to handle the fact that keyframe markers and current frame markers may now overlap.

Personally, I'm not 100% sure if this would really even be a problem, though I would certainly prioritize the keyframe marker. (It is generally easy to guess where the video playhead "should be", though I don't even see it being all too relevant in this case.) But, if we want to avoid it (reasonable), a 1px shift seems most logical to me (though it might not still be too easy to distinguish two adjacent vertical lines like that).

That said, I have slight personal preference to, if possible, keeping the video-playhead cursor visually positioned "on" the frame timestamp. However, I realize this is purely based on opinion, and is not even clearly always "desirable" (just as, to me, it is more "helpful" to see the video playhead indicator slightly offset from properly-frame-snapped times, it might be more confusing to someone else as to why lines are not snapped "correctly onto" the indicator). Most realistically, this is just not feasible.

Visual clarification of above paragraph

To make clear what I mean, I have grown used to recognizing timing like this (where the line start marker is directly on the playhead marker) as "bad":
image
and timing like this (where the line marker is slightly right of the line start time) as "good":
image

Meanwhile, with my suggestion, someone snapping a line's end time to the cursor would see this, and might be very understandably confused:
image

Lots of text incoming, since timestamp wrangling is hell and I want to
write down my reasoning before I inevitably forget it again in two
weeks.

Before commit 5d4973a, snapping an
audio line's end time to the "current video position" indicator line
would reliably make the line end on the frame before the current video
frame (i.e. make the current video frame be the first frame where the
selected line is *not* visible any more).

Commit 5d4973a broke this, making the
behavior of snapping audio times to the "current video position"
inconsistent.

The commit in question is definitely not fully correct, ultimately just
because the entire concept of implicitly converting millisecond
timestamps to centisecond timestamps is flawed in and of itself, and
bound to always fail in sufficiently crazy edge cases. Fixing the
timestamp conversion properly would entail either working with
centisecond timestamps from the beginning, or somehow making the process
of converting timestamps aware of the context the timestamps are from
(e.g. "coming from some frame timestamp").

However, this specific issue was only *exposed* by this commit, and not
solely caused by it. Its root cause was just that the "current video
position" marker on the audio display would mark the *exact* time of the
current video frame, rather than the ideal start/end time for a line to
start/end at that video frame. This is why only snapping to the "current
video position" broke while snapping to keyframes worked fine. It's
quite possible that snapping to the "current video frame" marker was
just never thought of as a use case.

So, for now, #421 can just be fixed by
making a line snapped to the "current video position" marker snap to the
middle of the frame rather than at the frame's exact start, and
5d4973a can be untangled at some later
time.

We still *draw* the "current video position" marker at the exact start
of the frame so that one can read off the audio display which lines are
visible on the current frame, only the *snap* position is changed. This
does mean that snapping a line to the marker snaps the line to a
position that's slightly *away* from the marker, but my impression is
that this does not actually cause too much confusion.

Fixes #421.
@arch1t3cht arch1t3cht force-pushed the fix-snap-video-pos branch from 9a67aa5 to c4a7ab3 Compare June 11, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistency When Snapping Markers to Cursor Time

2 participants