Skip to main content

Documentation Index

Fetch the complete documentation index at: https://tech.illasoft.com/llms.txt

Use this file to discover all available pages before exploring further.

概述

Video 模块是 Kira 的视频生成和播放工作区,支持文生视频 (t2v) 和图生视频 (i2v),与图片编辑器共享同一个 Generator 页面。

组件层次

核心组件

CanvasVideoPlayer

主视频播放器,位于 Generator 和 Rewind 页面。
components/feature/common/generator/canvas-video-player.tsx
功能说明
Video.js 播放器HTML5 视频播放
响应式布局根据容器自适应尺寸
状态占位卡片pending/processing 旋转渐变边框、failed 红色边框
VideoPlayerControls播放/暂停、进度条、音量、全屏

VideoPlayerControls

视频播放控制栏。
components/feature/common/generator/video-player-controls.tsx
控件说明
播放/暂停居中大按钮 + 底部栏按钮
进度条拖拽定位,显示缓冲进度
时间显示MM:SS 格式
音量滑块弹出(仅桌面端)
全屏浏览器全屏 API

VideoSelector

视频生成配置面板,用户点击 VideoGenerate 按钮后弹出。
components/feature/common/generator/video-selector.tsx
配置项说明
起始帧上传/选择起始图片 (i2v 模式)
提示词文本描述动作和运动
比例16:9 / 9:16 / 1:1 / auto
时长5 秒 / 10 秒

VideoGenerationCard

聊天消息中的视频生成状态卡片。
components/feature/common/chat/message/assistant/video-generation-card.tsx
状态展示
pending / processing旋转渐变边框 + loading 动画
completed视频就绪
failed错误信息 + 重试按钮
insufficient_credits / plan升级/充值引导

MediaSelector

底部媒体切换轮播,支持图片和视频混合展示。
components/feature/common/generator/media-selector.tsx
  • 合并图片、视频和音频,按 createdAt 排序
  • 视频缩略图带播放图标
  • 生成中的视频显示旋转渐变边框

工具栏

PC 端

工具栏位置包含
PCVideoToolBar右侧边栏VideoGenerate 按钮
PCVideoTopToolBar顶部居中NewThread, Upload, VideoExport, Backward, Forward, Delete

移动端

工具栏位置包含
MobileVideoToolBar底部AI 标签页: VideoGenerate;Basic 标签页: VideoExport, Backward, Forward, Delete
移动端视频工具栏使用 AI/Basic 标签页切换,与移动端图片工具栏保持一致的交互模式。

视频编辑工具(2026-03+)

除了生成视频外,还支持对已生成/上传视频的二次加工。每个工具有独立 EditMode + Selector,走 Inngest 异步。
工具EditModeSelector后端 tool
TrimtrimVideoVideoTrimSelectortrimVideo (0 credits)
EditvideoEditVideoEditSelectorvideoEdit (duration × 15)
ExtendvideoExtendVideoExtendSelectorvideoExtend (duration × 15)
Motion ControlmotionControlMotionControlSelectormotionControl (duration × 15)

Video Edit

上传 1-4 张参考图片作为关键帧 + prompt,用 WAN 2.7 Pro 或 KIE Seedance 2 生成新视频。

Video Extend

选择目标时长,从当前视频最后一帧继续生成。WAN 2.7 Pro。

Video Trim

纯前端 timeline UI,选 start/end 区间,后端 ffmpeg 剪切(0 credits)。

Motion Control

上传源图 + 描述人物动作,TencentCloud Kling VOD 生成视频(image → video)。

视频生成流程

1

进入视频生成模式

用户点击 VideoGenerate 按钮 → editMode = "generateVideo"
2

配置参数

VideoSelector 面板展开,用户设置提示词、比例、时长、起始帧
3

发送请求

确认后通过 function-call 格式发送 generateVideo 到 AI Agent
4

实时状态更新

WebSocket 推送视频状态变更,UI 实时更新
5

播放视频

生成完成后 CanvasVideoPlayer 自动加载播放

实时通知

通过 Centrifugo WebSocket 接收视频状态更新:
hooks/useVideoNotificationHandler.ts
消息类型处理
video_status统一通知类型,根据 video.status 字段更新 versions 缓存、当前选中视频、消息列表

更新目标

  1. Versions 缓存 — TanStack Query 数据中的视频列表
  2. 当前选中视频 — Zustand store 中的 currentSelectVideo
  3. Messages 缓存 — 聊天消息列表中的视频生成卡片

状态管理

// store/poisson.ts
interface Poisson {
  currentSelectVideo?: Video;
  currentSelectMediaType: "image" | "video" | "audio";
  editMode: EditMode;  // 含 generateVideo / trimVideo / videoEdit / videoExtend / motionControl
}
方法说明
setCurrentSelectVideo(threadId, video)设置当前选中视频
getCurrentSelectMediaType(threadId)获取当前媒体类型
setEditMode(threadId, "generateVideo")进入视频生成模式
setEditMode(threadId, "trimVideo" | "videoEdit" | ...)进入视频编辑工具

视频数据模型

// 新的 envelope 结构(input/output 分离),对应 kira-be VideoSchema
interface Video {
  taskId: string;
  toolCallId?: string;
  toolName?: string;
  provider: string;      // seedance / grok / ws-wan27 / kie-seedance2 / motion-control-tencentcloud-vod-kling
  status: "pending" | "processing" | "completed" | "failed"
    | "insufficient_credits" | "insufficient_plan";
  createdAt: string;
  errorMessage?: string | null;
  errorCode?: string | null;

  input: {
    prompt?: string;
    sourceImageId?: string;
    sourceVideoId?: string;       // videoEdit / videoExtend / trimVideo
    sourceMedias?: string[];      // videoEdit 参考图
    duration?: number;
    ratio?: string;
    trimStart?: number;
    trimEnd?: number;
    imageId?: string;             // motionControl 起始帧
  };

  output?: {
    videoId: string;
    thumbId: string;
    width: number;
    height: number;
    duration: number;
  };

  // 后端返回时补签名 URL
  url?: string;
  thumbUrl?: string;
  blurhash?: string;
}
旧的 v4 flat 格式(没有 input/output 分层)由 kira-be 的 Zod transform 自动迁移。

Hooks

Hook文件说明
useVideoPlayeruse-video-player.tsVideo.js 播放器状态 (play/pause/seek/volume)
useSubmitVideoTaskuseSubmitVideoTask.ts重新提交被阻塞的视频任务
useVideoNotificationHandleruseVideoNotificationHandler.tsWebSocket 视频状态通知处理

Feed 视频

视频可以发布到用户 Feed:
平台组件路径
PCPCFeedVideocomponents/feature/pc/feed/pc-feed-video.tsx
MobileMobileFeedVideocomponents/feature/mobile/feed/mobile-feed-video.tsx
使用原生 HTML5 <video> 播放,响应式适配容器宽高比。