Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed optimization #21

Open
xixihao123 opened this issue Aug 20, 2019 · 7 comments
Open

Delayed optimization #21

xixihao123 opened this issue Aug 20, 2019 · 7 comments

Comments

@xixihao123
Copy link

Hi, when I used the ffmpet push camera and then played RTSP video with player, I found that the delay was about 1 second, mainly caused by the displayRunnable() thread, and if deleted
for (;;)
{
const double delay = m_videoStartClock + current_frame.m_pts - GetHiResTime();
if (delay < 0.005)
break;
if (delay > 0.1)
{
boost::this_thread::sleep_for(
boost::chrono::milliseconds(100 * speedDenominator / speedNumerator));
continue;
}

        boost::this_thread::sleep_for(
            boost::chrono::milliseconds(int(delay * 1000. * speedDenominator / speedNumerator)));
        break;
    }

There will be no delay, but it will cause the audio and video to be out of sync.
How can we optimize it?

@aliakseis
Copy link
Owner

Hi,

Could you please try commenting this line:

if (!context.initialized || inNextFrame)

    //if (!context.initialized || inNextFrame)
    {
        m_videoStartClock = (m_isPaused ? m_pauseTimer : GetHiResTime()) - pts;
    }

@xixihao123
Copy link
Author

I 've already tried. comment the line. There's no delay. Using OBS to push the camera will be a little bit video and audio are out of sync. Can you shorten the display time?

@aliakseis
Copy link
Owner

Just to be sure. You mentioned another code line. Have you tried this one?

@xixihao123
Copy link
Author

image
What do you mean? I only commented on this line of code, and the audio was about a second slower when I pushed it

@aliakseis
Copy link
Owner

I am sorry, it looked like you were talking about the line with boost::this_thread::sleep_for() previously

@xixihao123
Copy link
Author

The problem is not very large, playing video stream, think RTSP playing video delay should be only about 200 MS

@aliakseis
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants