浏览代码

控制gpu帧率

leon 1 月之前
父节点
当前提交
6464e4c17b
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 2 0
      src/nodes/stream/streamNode.cpp
  2. 2 2
      src/nodes/stream/streamNode.hpp

+ 2 - 0
src/nodes/stream/streamNode.cpp

@@ -66,6 +66,8 @@ void StreamNode::work_gpu()
     unsigned int frame_index = 0;
 
     if (target_fps_ > 0.0) {
+        target_duration_ = std::chrono::duration_cast<std::chrono::microseconds>(
+            std::chrono::duration<double>(1.0 / fps_));
         last_push_time_ = std::chrono::high_resolution_clock::now();
     }
 

+ 2 - 2
src/nodes/stream/streamNode.hpp

@@ -100,10 +100,10 @@ private:
     StreamStatus status_ = StreamStatus::CLOSED;
 
 
-    double target_fps_; // Desired output FPS (0 or negative means no control)
+    double target_fps_ = 25; // Desired output FPS (0 or negative means no control)
     std::chrono::microseconds target_duration_{0}; // Duration per frame
     std::chrono::time_point<std::chrono::high_resolution_clock> last_push_time_; // Time when the last frame was pushed
-    
+
 };
 
 }