Even better frame pacing
This commit is contained in:
+2
-2
@@ -1005,9 +1005,9 @@ namespace rtsp_stream {
|
|||||||
config.monitor.enableIntraRefresh = util::from_view(args.at("x-ss-video[0].intraRefresh"sv));
|
config.monitor.enableIntraRefresh = util::from_view(args.at("x-ss-video[0].intraRefresh"sv));
|
||||||
|
|
||||||
if (config::video.limit_framerate) {
|
if (config::video.limit_framerate) {
|
||||||
config.monitor.encodingFramerate = (int)ceil(session.fps / 1000);
|
config.monitor.encodingFramerate = session.fps;
|
||||||
} else {
|
} else {
|
||||||
config.monitor.encodingFramerate = config.monitor.framerate;
|
config.monitor.encodingFramerate = config.monitor.framerate * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.monitor.input_only = session.input_only;
|
config.monitor.input_only = session.input_only;
|
||||||
|
|||||||
+11
-12
@@ -1901,7 +1901,7 @@ namespace video {
|
|||||||
|
|
||||||
// set minimum frame time, avoiding violation of client-requested target framerate
|
// set minimum frame time, avoiding violation of client-requested target framerate
|
||||||
auto minimum_frame_time = std::chrono::milliseconds(1000 / std::min(config.framerate, (config::video.min_fps_factor * 10)));
|
auto minimum_frame_time = std::chrono::milliseconds(1000 / std::min(config.framerate, (config::video.min_fps_factor * 10)));
|
||||||
auto frame_threshold = std::chrono::milliseconds(1000 / config.encodingFramerate);
|
auto frame_threshold = std::chrono::microseconds(1000ms * 1000 / config.encodingFramerate);
|
||||||
BOOST_LOG(debug) << "Minimum frame time set to "sv << minimum_frame_time.count() << "ms, based on min fps factor of "sv << config::video.min_fps_factor << "."sv;
|
BOOST_LOG(debug) << "Minimum frame time set to "sv << minimum_frame_time.count() << "ms, based on min fps factor of "sv << config::video.min_fps_factor << "."sv;
|
||||||
BOOST_LOG(info) << "Frame threshold: "sv << frame_threshold;
|
BOOST_LOG(info) << "Frame threshold: "sv << frame_threshold;
|
||||||
|
|
||||||
@@ -1983,19 +1983,18 @@ namespace video {
|
|||||||
} else if (!images->running()) {
|
} else if (!images->running()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (frame_timestamp) {
|
if (frame_timestamp) {
|
||||||
auto frame_diff = *frame_timestamp - next_frame_start;
|
auto frame_diff = *frame_timestamp - next_frame_start;
|
||||||
if (frame_diff < 2ms) {
|
|
||||||
auto this_frame_timestamp = next_frame_start;
|
if (frame_diff > frame_threshold) {
|
||||||
next_frame_start = *frame_timestamp;
|
next_frame_start = *frame_timestamp - frame_threshold / 2;
|
||||||
frame_timestamp = this_frame_timestamp;
|
}
|
||||||
} else if (frame_diff > frame_threshold) {
|
|
||||||
next_frame_start = *frame_timestamp - frame_threshold / 2;
|
frame_timestamp = next_frame_start;
|
||||||
|
|
||||||
|
next_frame_start += frame_threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
next_frame_start += frame_threshold;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encode(frame_nr++, *session, packets, channel_data, frame_timestamp)) {
|
if (encode(frame_nr++, *session, packets, channel_data, frame_timestamp)) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user