aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-10-12 01:12:15 +0200
committerdec05eba <dec05eba@protonmail.com>2024-10-12 01:12:15 +0200
commit9248663666dbe64bf7c60575ffc9fb420874ae20 (patch)
tree9ce3fd88bc5af057a38828140f0717807a31b3a2 /src
parentfff68b8a18f96ee6ba4583c57bc6206e750fad37 (diff)
Better frame timing when frame encoding time overflows
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp8
1 files changed, 5 insertions, 3 deletions
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;