mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-06-23 04:59:37 -04:00
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:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user