Skip to content

Commit

Permalink
success
Browse files Browse the repository at this point in the history
  • Loading branch information
TalusL committed Jun 13, 2024
1 parent 1fb63a2 commit d3650ff
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/QQuickRealTimePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ shared_ptr<AVFrame> QQuickRealTimePlayer::getFrame(bool &got) {
// 计算一帧的显示时间
auto frameDuration = 1000 / decoder->GetFps();
// 缓冲,追帧机制
if (videoFrameQueue.size() * frameDuration < 100.0) {
std::this_thread::sleep_for(std::chrono::milliseconds((int)frameDuration));
} else {
if (videoFrameQueue.size() < 5) {
double scale = videoFrameQueue.size() * frameDuration / 100.0;
std::this_thread::sleep_for(
std::chrono::milliseconds((int)(frameDuration / scale)));
Expand Down Expand Up @@ -154,6 +152,9 @@ void QQuickRealTimePlayer::play(const QString &playUrl) {
{
// 解码获取到视频帧,放入帧缓冲队列
lock_guard<mutex> lck(mtx);
if(videoFrameQueue.size()>10) {
videoFrameQueue.pop();
}
videoFrameQueue.push(frame);
}
} catch (const exception &e) {
Expand Down

0 comments on commit d3650ff

Please sign in to comment.