4308621845d4d028968b60f0434beb0a45a73183
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m9s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m12s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m14s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 4m40s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 5m33s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 5m44s
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
## 问题
用户反馈最终生成视频中标题字体比模板预览/选择时看到的小很多。
前端 titleCanvas.ts 已明确 titleConfig.size 的语义是「720p 基准宽度下的 px 字号」,
按 scale = videoWidth/720 缩放渲染到预览 Canvas;但后端三个渲染路径
(ass_subtitle_builder / drawtext 降级 / subtitle_generator ASR)直接使用原始 size 值,
在 1080×1920 竖屏/1920×1080 横屏等非 720p 输出下,标题字号未随分辨率等比放大,
导致成片标题明显小于前端预览。
此外 apps/worker/video_processing/subtitle_generator.py 中存在
`min(int(title_cfg.get("size", 36)), 36)` 的上限钳位,任何分辨率下标题字号
都会被强行压到 ≤36,进一步放大了问题。
## 修复
三个渲染路径统一以 720p 为基准,按 video_width/720 等比缩放所有长度类参数:
- packages/domain/ass_subtitle_builder.py
- 新增 _scale_len(value, video_width) 工具:整数输入返回 int,浮点输入保留 float
- build_ass_content 内新增 _scale_cfg(cfg, defaults) 内部函数:
先 setdefault 填充 size 默认值(title=36、subtitle=24),再统一缩放
size/font_size、margin_top/bg_padding/bg_radius、line_overrides[*].size;
pos_x/pos_y 是百分比(0-100)不缩放
- 描边宽(默认 2)、阴影 blur(默认 4)、阴影 offset_x/y(默认 2)在字段提取
处经 _scale_len 缩放,避免双重缩放
- TITLE_MARGIN_TOP/BOTTOM/SIDE 常量经 _scale_len 成局部 _margin_top/bottom/side
- subtitle outline_width(1.0)经 _scale_len 缩放(保持 float 以支持 1.5 等小数)
- packages/domain/video_filter_builder.py (build_title_drawtext_filter 降级路径)
- 新增 _scale_title_len(value, output_width) 工具
- font_size、border_width(描边)、shadowx/shadowy(阴影偏移)、top/bottom 位置
y 偏移(50px)统一按 output_width/720 缩放
- apps/worker/video_processing/subtitle_generator.py (ASR 时间轴字幕路径)
- 复用 ass_subtitle_builder._scale_len
- subtitle: font_size 默认 24、outline_width 默认 1.5、margin_v/l/r 默认 60/40/40
全部按 video_width/720 缩放
- title: 移除 min(..., 36) 上限钳位;s_width/sh_blur/sh_offset、margin_top/side
统一缩放;_wrap_title_text 传入缩放后的 margin_l/r
## 不缩放的字段
颜色/字体/对齐/粗体/斜体等枚举/布尔值不缩放;
pos_x/pos_y 为百分比(0-100)不缩放;
AI 数字人 WYSIWYG PNG overlay 路径(build_title_overlay_filter)由前端 Canvas 按
videoWidth 直接绘制,后端只 overlay=0:0 叠加,无需后端缩放。
## 测试
- 既有断言固定值的单测:将 video_width 改为 720(720p 基准下缩放比=1,断言值不变)
- 新增 TestTitleFontsizeScaling / TestDrawtextFontsizeScaling 共 16 个测试用例:
720p 不变、1080p 1.5×、1920p 8/3×、描边宽/阴影偏移/边距/位置边距/逐行覆盖 size
等场景
- 修正 test_subtitle_generator.py::test_720p_resolution 中 PlayResX/Y 与
video_width/height 互换的断言错误
- 全量单测:15978 passed, 2 failed(均为 test_1970_musetalk_server.py 中
ffmpeg 超时/FileNotFound 的 flaky,与本次改动无关,在 develop HEAD 上复现)
28 skipped
小虾 SaaS - 自动化视频剪辑平台
自动化视频剪辑 SaaS 平台,支持素材上传、AI 分类、智能剪辑计划生成、自动化视频合成与成片管理。
✨ 核心功能
🎬 视频剪辑主链路
- 素材上传(直传 OSS + 分片上传大文件,最大 2GB)
- AI 智能分类与质量评分
- 4 种剪辑模式:one_take / pip(画中画)/ voice_over(口播+B-roll)/ voice_pip
- 剪辑计划模板 + 智能生成
- 自动化视频合成任务(Celery 异步)
- 成片下载与审核管理
- 资产诊断(素材就绪度评估、缺口分析)
🔐 认证系统
- JWT Bearer Token 认证
- 邮箱注册 + 邮箱验证
- 密码重置(邮箱找回)
- bcrypt 密码加密
📋 项目管理
- 项目 CRUD + 共享
- 任务管理(创建/更新/状态流转/进度追踪)
- 里程碑管理
- 任务问题追踪
📊 素材库管理
- 素材库创建与管理
- 素材上传、审核状态流转(pending_review → approved/rejected)
- 素材诊断(就绪度评分、缺口分析、智能视图)
🚀 快速开始
方式 1: Docker Compose(推荐)
# 1. 克隆仓库
git clone https://git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas.git
cd xiaoxia-saas
# 2. 配置环境变量
cp .env.example .env
# 编辑 .env 填写数据库、Redis、OSS 等配置
# 3. 启动所有服务
docker-compose up -d
# 4. 访问 API 文档
open http://localhost:8000/docs
方式 2: 本地开发
# 1. 克隆仓库
git clone https://git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas.git
cd xiaoxia-saas
# 2. 创建虚拟环境
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. 安装依赖
pip install -r requirements.txt
# 4. 配置环境变量
cp .env.example .env
# 5. 启动 API 服务
uvicorn apps.api.main:app --reload
# 6. 访问 API 文档
open http://localhost:8000/docs
📚 API 文档
交互式文档
- Swagger UI: https://saas-api.xiaoxiajianji.com/docs
- OpenAPI Schema: https://saas-api.xiaoxiajianji.com/openapi.json
核心 API 路径
认证 (/api/v1/auth)
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /register |
用户注册 |
| POST | /login |
用户登录 |
| GET | /me |
获取当前用户信息 |
| POST | /password/forgot |
忘记密码 |
| POST | /password/reset |
重置密码 |
视频剪辑主链路
上传素材 → POST /api/v1/upload(直传)或 /api/v1/upload/chunk/init(分片)
↓
创建素材 → POST /api/v1/assets
↓
AI 分类 → POST /api/v1/classification-jobs
↓
生成剪辑计划 → POST /api/v1/projects/{id}/edit-plans/auto-generate
↓
创建生成任务 → POST /api/v1/generation/tasks/
↓
查询结果 → GET /api/v1/generation/tasks/{task_id}/results/
↓
获取成片 → GET /api/v1/generated-videos/{video_id}/download-url
项目管理 (/api/v1/project-management)
| 方法 | 路径 | 说明 |
|---|---|---|
| GET/POST | /tasks |
任务列表/创建 |
| PATCH | /tasks/{id} |
更新任务信息 |
| PATCH | /tasks/{id}/status |
更新任务状态 |
| PATCH | /tasks/{id}/progress |
更新任务进度 |
| GET/POST | /milestones |
里程碑列表/创建 |
| GET/POST | /issues |
问题列表/创建 |
| PATCH | /issues/{id}/resolve |
解决问题 |
素材与上传
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /api/v1/upload |
直传素材(multipart/form-data) |
| POST | /api/v1/upload/direct/prepare |
准备 OSS 直传签名 |
| POST | /api/v1/upload/direct/complete |
确认直传完成 |
| POST | /api/v1/upload/chunk/init |
初始化分片上传 |
| POST | /api/v1/upload/chunk/{id}/{index} |
上传分片 |
| POST | /api/v1/upload/chunk/{id}/complete |
完成分片上传 |
| GET | /api/v1/assets |
素材列表 |
| PATCH | /api/v1/assets/{id}/review |
更新素材审核状态 |
| GET | /api/v1/projects/{id}/asset-diagnosis |
资产诊断 |
成片管理 (/api/v1/generated-videos)
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | / |
成片列表 |
| GET | /{video_id} |
成片详情 |
| GET | /{video_id}/download-url |
下载链接 |
| PATCH | /{video_id}/review |
审核状态 |
完整 API 列表请查看 API 主线清单
🏗️ 架构
小虾 SaaS
├── packages/ # 核心业务逻辑(Clean Architecture)
│ ├── domain/ # 领域模型(dataclass)
│ ├── application/ # 用例(Use Cases)
│ ├── ports/ # 接口定义(抽象端口)
│ └── adapters/ # 适配器实现(SQLAlchemy、Redis、SMTP 等)
├── apps/ # 应用层
│ ├── api/ # FastAPI 应用 + 路由 + Pydantic schemas
│ ├── web/ # React + Vite 前端
│ └── worker/ # Celery 异步任务(视频处理、分类等)
├── migrations/ # Alembic 数据库迁移
├── tests/ # 测试
│ ├── unit/ # 单元测试
│ ├── integration/ # 集成测试
│ └── e2e/ # 端到端测试
└── docs/ # 文档
设计模式:
- Clean Architecture(依赖方向:外层 → 内层)
- 依赖注入(FastAPI Depends)
- Repository 模式(通过 ports 抽象)
- Domain-Driven Design
🛠️ 技术栈
后端:
- Python 3.12 + FastAPI 0.115.0
- PostgreSQL 16(生产)
- Redis 7(缓存 + Celery Broker)
- Celery(异步任务:视频处理、素材导入、分类)
- 阿里云 OSS(文件存储)
前端:
- React 18 + TypeScript
- Vite(构建工具)
- Ant Design(UI 组件)
部署:
- Docker + Docker Compose
- Gitea + Gitea Actions(CI/CD)
- Nginx(反向代理)
🧪 测试
# 运行所有测试
pytest tests/ -v
# 运行单元测试
pytest tests/unit -v
# 运行集成测试
pytest tests/integration -v
# 生成覆盖率报告
pytest --cov=packages --cov-report=html
📊 当前状态
| 模块 | 状态 |
|---|---|
| 视频剪辑主链路(Phase 7) | ✅ 已完成 |
| 分片上传(最大 2GB) | ✅ 已完成 |
| 4 种剪辑模式 | ✅ 已完成 |
| 项目管理 + 任务追踪 | ✅ 已完成 |
| 资产诊断 | ✅ 已完成 |
| 认证系统(JWT) | ✅ 已完成 |
| CI/CD 流水线 | ✅ 运行中 |
| 前端界面(Vite) | ✅ 已完成 |
📄 更多文档
🤝 贡献
欢迎贡献!请查看 贡献指南
仓库地址: https://git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas
License: MIT
Releases
7
v2.1.0-test.9
Latest
Languages
Python
78.5%
TypeScript
15.8%
CSS
2.8%
Shell
2.7%
Dockerfile
0.1%
Other
0.1%