Kling Camera Controls 节点用于定义虚拟摄像机的行为参数,控制Kling视频生成过程中的镜头运动和视角变化。

参数说明

参数类型默认值说明
camera_control_type选择项”simple”预定义的摄像机运动类型。simple: 可自定义的摄像机运动;down_back: 摄像机下降并向后移动;forward_up: 摄像机向前移动并向上倾斜;right_turn_forward: 向右旋转并向前移动;left_turn_forward: 向左旋转并向前移动
horizontal_movement浮点数0控制摄像机沿水平轴(x轴)的移动。负值表示向左,正值表示向右
vertical_movement浮点数0控制摄像机沿垂直轴(y轴)的移动。负值表示向下,正值表示向上
pan浮点数0.5控制摄像机在垂直平面上的旋转(x轴)。负值表示向下旋转,正值表示向上旋转
tilt浮点数0控制摄像机在水平平面上的旋转(y轴)。负值表示向左旋转,正值表示向右旋转
roll浮点数0控制摄像机的滚动量(z轴)。负值表示逆时针,正值表示顺时针
zoom浮点数0控制摄像机焦距的变化。负值表示视场变窄,正值表示视场变宽

注意:至少需要一个非零值的摄像机控制参数才有效。

输出

输出类型说明
camera_controlCAMERA_CONTROL包含摄像机设置的配置对象

注意:并非所有模型和模式组合都支持摄像机控制。请参考Kling API文档了解更多信息。

源码参考

[节点源码 (更新于2025-05-03)]


class KlingCameraControls(KlingNodeBase):
    """Kling Camera Controls Node"""

    @classmethod
    def INPUT_TYPES(cls):
        return {
            "required": {
                "camera_control_type": (
                    IO.COMBO,
                    {
                        "options": [
                            camera_control_type.value
                            for camera_control_type in CameraType
                        ],
                        "default": "simple",
                        "tooltip": "Predefined camera movements type. simple: Customizable camera movement. down_back: Camera descends and moves backward. forward_up: Camera moves forward and tilts up. right_turn_forward: Rotate right and move forward. left_turn_forward: Rotate left and move forward.",
                    },
                ),
                "horizontal_movement": get_camera_control_input_config(
                    "Controls camera's movement along horizontal axis (x-axis). Negative indicates left, positive indicates right"
                ),
                "vertical_movement": get_camera_control_input_config(
                    "Controls camera's movement along vertical axis (y-axis). Negative indicates downward, positive indicates upward."
                ),
                "pan": get_camera_control_input_config(
                    "Controls camera's rotation in vertical plane (x-axis). Negative indicates downward rotation, positive indicates upward rotation.",
                    default=0.5,
                ),
                "tilt": get_camera_control_input_config(
                    "Controls camera's rotation in horizontal plane (y-axis). Negative indicates left rotation, positive indicates right rotation.",
                ),
                "roll": get_camera_control_input_config(
                    "Controls camera's rolling amount (z-axis). Negative indicates counterclockwise, positive indicates clockwise.",
                ),
                "zoom": get_camera_control_input_config(
                    "Controls change in camera's focal length. Negative indicates narrower field of view, positive indicates wider field of view.",
                ),
            }
        }

    DESCRIPTION = "Kling Camera Controls Node. Not all model and mode combinations support camera control. Please refer to the Kling API documentation for more information."
    RETURN_TYPES = ("CAMERA_CONTROL",)
    RETURN_NAMES = ("camera_control",)
    FUNCTION = "main"

    @classmethod
    def VALIDATE_INPUTS(
        cls,
        horizontal_movement: float,
        vertical_movement: float,
        pan: float,
        tilt: float,
        roll: float,
        zoom: float,
    ) -> bool | str:
        if not is_valid_camera_control_configs(
            [
                horizontal_movement,
                vertical_movement,
                pan,
                tilt,
                roll,
                zoom,
            ]
        ):
            return "Invalid camera control configs: at least one of the values must be non-zero"
        return True

    def main(
        self,
        camera_control_type: str,
        horizontal_movement: float,
        vertical_movement: float,
        pan: float,
        tilt: float,
        roll: float,
        zoom: float,
    ) -> tuple[CameraControl]:
        return (
            CameraControl(
                type=CameraType(camera_control_type),
                config=CameraConfig(
                    horizontal=horizontal_movement,
                    vertical=vertical_movement,
                    pan=pan,
                    roll=roll,
                    tilt=tilt,
                    zoom=zoom,
                ),
            ),
        )