fix: improve montage review playback smoothness and fix video seek overshoot

Fix FFmpeg initial seek overshooting to a future keyframe when the
requested timestamp falls between keyframes. After the initial
AVSEEK_FLAG_FRAME seek, detect if the returned frame is past the
target and re-seek backward to get the correct keyframe before it.

On the JS side, preserve fractional seconds throughout the playback
pipeline: remove Math.floor() truncation in mmove() and setSpeed(),
and use parseFloat instead of parseInt for currentTimeSecs
initialization. Reduce initial display interval from 1000ms to 100ms
for ~10fps refresh rate during review playback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Isaac Connor
2026-02-26 13:16:07 -05:00
parent 61b025b85f
commit 2b14e9044e
4 changed files with 18 additions and 7 deletions

View File

@@ -283,6 +283,18 @@ AVFrame *FFmpeg_Input::get_frame(int stream_id, double at) {
Warning("Unable to get frame.");
return nullptr;
}
// If the initial seek landed past the target (on a future keyframe),
// re-seek backward to get the keyframe before the target instead.
if (frame->pts > seek_target) {
Debug(1, "Initial seek overshot: frame pts %" PRId64 " > seek_target %" PRId64 ", seeking backward",
frame->pts, seek_target);
ret = av_seek_frame(input_format_context, stream_id, seek_target,
AVSEEK_FLAG_BACKWARD);
if (ret >= 0) {
get_frame(stream_id);
}
}
} // end if ! frame
if (