Skip to content

Commit

Permalink
Fixed video stuttering
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oomek committed Mar 19, 2019
1 parent fe7bf4d commit 02609a7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
{
Expand Down Expand Up @@ -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 )
{
Expand Down

0 comments on commit 02609a7

Please sign in to comment.