mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
new ustreamer and fps max
This commit is contained in:
@@ -228,8 +228,9 @@ def _get_config_scheme(sections: List[str]) -> Dict:
|
||||
"shutdown_delay": Option(10.0, type=valid_float_f01),
|
||||
"state_poll": Option(1.0, type=valid_float_f01),
|
||||
|
||||
"quality": Option(80, type=valid_stream_quality),
|
||||
"desired_fps": Option(0, type=valid_stream_fps),
|
||||
"quality": Option(80, type=valid_stream_quality),
|
||||
"desired_fps": Option(0, type=valid_stream_fps),
|
||||
"max_fps": Option(120, type=valid_stream_fps),
|
||||
|
||||
"host": Option("localhost", type=valid_ip_or_host),
|
||||
"port": Option(0, type=valid_port),
|
||||
|
||||
@@ -55,6 +55,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
|
||||
quality: int,
|
||||
desired_fps: int,
|
||||
max_fps: int,
|
||||
|
||||
host: str,
|
||||
port: int,
|
||||
@@ -77,6 +78,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
"quality": quality,
|
||||
"desired_fps": desired_fps,
|
||||
}
|
||||
self.__max_fps = max_fps
|
||||
|
||||
assert port or unix_path
|
||||
self.__host = host
|
||||
@@ -95,9 +97,13 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
logger = get_logger()
|
||||
logger.info("Starting streamer ...")
|
||||
|
||||
self.__params = {key: params[key] for key in self.__params} # Only known params
|
||||
assert 1 <= self.__params["quality"] <= 100
|
||||
assert 0 <= self.__params["desired_fps"] <= 30
|
||||
self.__params = {
|
||||
key: min(max(params.get(key, self.__params[key]), a), b)
|
||||
for (key, a, b) in [
|
||||
("quality", 0, 100),
|
||||
("desired_fps", 0, self.__max_fps),
|
||||
]
|
||||
}
|
||||
|
||||
await self.__inner_start()
|
||||
if self.__init_restart_after > 0.0 and not no_init_restart:
|
||||
@@ -134,6 +140,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
except Exception:
|
||||
get_logger().exception("Invalid streamer response from /state")
|
||||
return {
|
||||
"limits": {"max_fps": self.__max_fps},
|
||||
"params": self.get_params(),
|
||||
"state": state,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user