From 02609a798ee5facef72b41beb2e20299381d3561 Mon Sep 17 00:00:00 2001 From: Radek Dutkiewicz Date: Tue, 19 Mar 2019 01:17:40 +0000 Subject: [PATCH] Fixed video stuttering Adding a half frame offset to wait time seems to fix framerate fluctuations so the main thread has time to update the texture before it's replaced with a new one. --- src/media.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/media.cpp b/src/media.cpp index 2b43703fe..29b0fc02f 100644 --- a/src/media.cpp +++ b/src/media.cpp @@ -605,6 +605,7 @@ void FeVideoImp::video_thread() int64_t prev_duration = 0; sf::Time wait_time; + sf::Time half_frame_offset = sf::milliseconds( 8 ); if ((!sws_ctx) || (!rgba_buffer[0])) { @@ -637,7 +638,7 @@ void FeVideoImp::video_thread() wait_time = sf::seconds( detached_frame->pts * av_q2d( m_parent->m_imp->m_format_ctx->streams[stream_id]->time_base )) - - m_parent->get_video_time(); + - m_parent->get_video_time() + half_frame_offset; if ( wait_time < max_sleep ) {