From 9248663666dbe64bf7c60575ffc9fb420874ae20 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 12 Oct 2024 01:12:15 +0200 Subject: Better frame timing when frame encoding time overflows --- src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 3f1b68c..d230e47 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3782,9 +3782,11 @@ int main(int argc, char **argv) { const double time_at_frame_end = clock_get_monotonic_seconds() - paused_time_offset; const double time_elapsed_total = time_at_frame_end - record_start_time; - //const int64_t frames_elapsed = std::round(time_elapsed_total / target_fps); - const double time_at_next_frame = (video_pts_counter + 1) * target_fps; - const double time_to_next_frame = time_at_next_frame - time_elapsed_total; + const int64_t frames_elapsed = (int64_t)(time_elapsed_total / target_fps); + const double time_at_next_frame = (frames_elapsed + 1) * target_fps; + double time_to_next_frame = time_at_next_frame - time_elapsed_total; + if(time_to_next_frame > target_fps*1.1) + time_to_next_frame = target_fps; //const double frame_end = clock_get_monotonic_seconds(); //const double frame_time = frame_end - frame_start; -- cgit v1.2.3