Fix snapping audio times to current video position#609
Open
arch1t3cht wants to merge 2 commits into
Open
Conversation
Contributor
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.
9a67aa5 to
c4a7ab3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.