Skip to content
Snippets Groups Projects
Commit 86db590e authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Limit FPS during encode

parent 5d16f00a
No related branches found
No related tags found
No related merge requests found
Pipeline #29398 failed
......@@ -399,7 +399,7 @@ ftl::cuda::TextureObject<uchar4>& Camera::getFrame(ftl::codecs::Channel channel)
if (std::atomic_load(&current_fs_)) {
auto& frame = current_fs_->frames[frame_idx].cast<ftl::rgbd::Frame>();
current_frame_colour_ = frame.getTexture<uchar4>(Channel::Left);
if (frame.hasChannel(Channel::Left)) current_frame_colour_ = frame.getTexture<uchar4>(Channel::Left);
if (frame.hasChannel(channel)) {
current_frame_ = colouriser_->colourise(frame, channel, 0);
......
......@@ -125,7 +125,8 @@ cv::Size ftl::rgbd::Frame::getSize(ftl::codecs::Channel c) const {
return f.getCPU().size();
}
} else {
throw FTL_Error("Channel does not exists: " << int(c));
//throw FTL_Error("Channel does not exists: " << int(c));
return cv::Size(0,0);
}
}
......
......@@ -74,6 +74,8 @@ class Sender : public ftl::Configurable {
int add_iframes_;
unsigned int iframe_;
ftl::Handle handle_;
int64_t last_ts_=0;
int min_frame_interval_=0;
struct EncodingState {
uint8_t bitrate;
......
......@@ -29,6 +29,11 @@ Sender::Sender(nlohmann::json &config) : ftl::Configurable(config), stream_(null
iframe_ = 1;
add_iframes_ = value("iframes", 50);
timestamp_ = -1;
min_frame_interval_ = 1000 / value("max_fps", 30);
on("max_fps", [this]() {
min_frame_interval_ = 1000 / value("max_fps", 30);
});
on("iframes", [this]() {
add_iframes_ = value("iframes", 50);
......@@ -294,6 +299,11 @@ void Sender::post(ftl::data::FrameSet &fs, ftl::codecs::Channel c, bool noencode
}
}
if (fs.timestamp() > last_ts_ && fs.timestamp() < last_ts_ + min_frame_interval_) {
return;
}
last_ts_ = fs.timestamp();
// Don't transmit if noencode and needs encoding
if (needs_encoding && noencode) {
needs_encoding = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment