mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
fix
This commit is contained in:
parent
3de55653fa
commit
30bc03fa39
@ -201,7 +201,19 @@ def _patch_raw(raw_config: Dict) -> None:
|
|||||||
if max_fps is not None:
|
if max_fps is not None:
|
||||||
if not isinstance(streamer_config.get("desired_fps"), dict):
|
if not isinstance(streamer_config.get("desired_fps"), dict):
|
||||||
streamer_config["desired_fps"] = {}
|
streamer_config["desired_fps"] = {}
|
||||||
streamer_config["desired_fps"] = {"max": max_fps}
|
streamer_config["desired_fps"]["max"] = max_fps
|
||||||
|
del streamer_config["max_fps"]
|
||||||
|
|
||||||
|
resolution = streamer_config.get("resolution")
|
||||||
|
if resolution is not None and not isinstance(resolution, dict):
|
||||||
|
streamer_config["resolution"] = {"default": resolution}
|
||||||
|
|
||||||
|
available_resolutions = streamer_config.get("available_resolutions")
|
||||||
|
if available_resolutions is not None:
|
||||||
|
if not isinstance(streamer_config.get("resolution"), dict):
|
||||||
|
streamer_config["resolution"] = {}
|
||||||
|
streamer_config["resolution"]["available"] = available_resolutions
|
||||||
|
del streamer_config["available_resolutions"]
|
||||||
|
|
||||||
|
|
||||||
def _patch_dynamic( # pylint: disable=too-many-locals
|
def _patch_dynamic( # pylint: disable=too-many-locals
|
||||||
@ -373,8 +385,15 @@ def _get_config_scheme() -> Dict:
|
|||||||
"state_poll": Option(1.0, type=valid_float_f01),
|
"state_poll": Option(1.0, type=valid_float_f01),
|
||||||
|
|
||||||
"quality": Option(80, type=_make_ifarg(valid_stream_quality, 0)),
|
"quality": Option(80, type=_make_ifarg(valid_stream_quality, 0)),
|
||||||
"resolution": Option("", type=_make_ifarg(valid_stream_resolution, "")),
|
|
||||||
"available_resolutions": Option([], type=functools.partial(valid_string_list, subval=valid_stream_resolution)),
|
"resolution": {
|
||||||
|
"default": Option("", type=_make_ifarg(valid_stream_resolution, ""), unpack_as="resolution"),
|
||||||
|
"available": Option(
|
||||||
|
[],
|
||||||
|
type=functools.partial(valid_string_list, subval=valid_stream_resolution),
|
||||||
|
unpack_as="available_resolutions",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
"desired_fps": {
|
"desired_fps": {
|
||||||
"default": Option(30, type=valid_stream_fps, unpack_as="desired_fps"),
|
"default": Option(30, type=valid_stream_fps, unpack_as="desired_fps"),
|
||||||
|
|||||||
@ -68,7 +68,8 @@ def main(argv: Optional[List[str]]=None) -> None:
|
|||||||
|
|
||||||
hid = get_hid_class(config.hid.type)(**hid_kwargs)
|
hid = get_hid_class(config.hid.type)(**hid_kwargs)
|
||||||
streamer = Streamer(
|
streamer = Streamer(
|
||||||
**config.streamer._unpack(ignore=["forever", "desired_fps", "h264_bitrate", "h264_gop"]),
|
**config.streamer._unpack(ignore=["forever", "desired_fps", "resolution", "h264_bitrate", "h264_gop"]),
|
||||||
|
**config.streamer.resolution._unpack(),
|
||||||
**config.streamer.desired_fps._unpack(),
|
**config.streamer.desired_fps._unpack(),
|
||||||
**config.streamer.h264_bitrate._unpack(),
|
**config.streamer.h264_bitrate._unpack(),
|
||||||
**config.streamer.h264_gop._unpack(),
|
**config.streamer.h264_gop._unpack(),
|
||||||
|
|||||||
@ -76,19 +76,19 @@ class _StreamerParams:
|
|||||||
desired_fps_max: int,
|
desired_fps_max: int,
|
||||||
|
|
||||||
h264_bitrate: int,
|
h264_bitrate: int,
|
||||||
h264_min_bitrate: int,
|
h264_bitrate_min: int,
|
||||||
h264_max_bitrate: int,
|
h264_bitrate_max: int,
|
||||||
|
|
||||||
h264_gop: int,
|
h264_gop: int,
|
||||||
h264_min_gop: int,
|
h264_gop_min: int,
|
||||||
h264_max_gop: int,
|
h264_gop_max: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
self.__has_quality = bool(quality)
|
self.__has_quality = bool(quality)
|
||||||
self.__has_resolution = bool(resolution)
|
self.__has_resolution = bool(resolution)
|
||||||
self.__has_h264 = bool(h264_bitrate)
|
self.__has_h264 = bool(h264_bitrate)
|
||||||
|
|
||||||
self.__params: Dict = {self.__DESIRED_FPS: min(desired_fps, desired_fps_min)}
|
self.__params: Dict = {self.__DESIRED_FPS: min(max(desired_fps, desired_fps_min), desired_fps_max)}
|
||||||
self.__limits: Dict = {self.__DESIRED_FPS: {"min": desired_fps_min, "max": desired_fps_max}}
|
self.__limits: Dict = {self.__DESIRED_FPS: {"min": desired_fps_min, "max": desired_fps_max}}
|
||||||
|
|
||||||
if self.__has_quality:
|
if self.__has_quality:
|
||||||
@ -99,10 +99,10 @@ class _StreamerParams:
|
|||||||
self.__limits[self.__AVAILABLE_RESOLUTIONS] = available_resolutions
|
self.__limits[self.__AVAILABLE_RESOLUTIONS] = available_resolutions
|
||||||
|
|
||||||
if self.__has_h264:
|
if self.__has_h264:
|
||||||
self.__params[self.__H264_BITRATE] = min(max(h264_bitrate, h264_min_bitrate), h264_max_bitrate)
|
self.__params[self.__H264_BITRATE] = min(max(h264_bitrate, h264_bitrate_min), h264_bitrate_max)
|
||||||
self.__limits[self.__H264_BITRATE] = {"min": h264_min_bitrate, "max": h264_max_bitrate}
|
self.__limits[self.__H264_BITRATE] = {"min": h264_bitrate_min, "max": h264_bitrate_max}
|
||||||
self.__params[self.__H264_GOP] = min(max(h264_gop, h264_min_gop), h264_max_gop)
|
self.__params[self.__H264_GOP] = min(max(h264_gop, h264_gop_min), h264_gop_max)
|
||||||
self.__limits[self.__H264_GOP] = {"min": h264_min_gop, "max": h264_max_gop}
|
self.__limits[self.__H264_GOP] = {"min": h264_gop_min, "max": h264_gop_max}
|
||||||
|
|
||||||
def get_features(self) -> Dict:
|
def get_features(self) -> Dict:
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user