Files
AI-Video/api/schemas/editor.py
empty 79a6c2ef3e feat: Add inpainting (局部重绘) feature for timeline editor
- Add canvas-based mask drawing tools (brush, eraser, rect, lasso)
- Add undo/redo history support for mask editing
- Integrate inpainting UI into preview player
- Add backend API endpoint for inpainting requests
- Add MediaService.inpaint method with ComfyUI workflow support
- Add Flux inpainting workflows for selfhost and RunningHub

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 23:44:51 +08:00

124 lines
3.7 KiB
Python

# Copyright (C) 2025 AIDC-AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Editor API schemas for timeline editor
"""
from pydantic import BaseModel, Field
from typing import List, Optional
from datetime import datetime
class StoryboardFrameSchema(BaseModel):
"""Schema for a single storyboard frame"""
id: str
index: int
order: int
narration: str
image_prompt: Optional[str] = None
image_path: Optional[str] = None
audio_path: Optional[str] = None
video_segment_path: Optional[str] = None
duration: float = 0.0
class Config:
from_attributes = True
class StoryboardSchema(BaseModel):
"""Schema for complete storyboard"""
id: str
title: str
frames: List[StoryboardFrameSchema]
total_duration: float
final_video_path: Optional[str] = None
created_at: Optional[datetime] = None
class Config:
from_attributes = True
class ReorderFramesRequest(BaseModel):
"""Request to reorder frames"""
order: List[str] = Field(..., description="List of frame IDs in new order")
class UpdateDurationRequest(BaseModel):
"""Request to update frame duration"""
duration: float = Field(..., ge=0.1, le=60.0, description="New duration in seconds")
class PreviewRequest(BaseModel):
"""Request to generate preview"""
start_frame: int = Field(0, ge=0, description="Start frame index")
end_frame: Optional[int] = Field(None, description="End frame index (None = to end)")
class PreviewResponse(BaseModel):
"""Response with preview video path"""
preview_path: str
duration: float
frames_count: int
class UpdateFrameRequest(BaseModel):
"""Request to update frame content"""
narration: Optional[str] = Field(None, description="Updated narration text")
image_prompt: Optional[str] = Field(None, description="Updated image generation prompt")
class UpdateFrameResponse(BaseModel):
"""Response after updating frame"""
id: str
narration: str
image_prompt: Optional[str]
updated: bool = True
class RegenerateImageRequest(BaseModel):
"""Request to regenerate frame image"""
image_prompt: Optional[str] = Field(None, description="Override prompt for regeneration")
class RegenerateImageResponse(BaseModel):
"""Response after regenerating image"""
image_path: str
success: bool = True
class RegenerateAudioRequest(BaseModel):
"""Request to regenerate frame audio"""
narration: Optional[str] = Field(None, description="Override narration for regeneration")
voice: Optional[str] = Field(None, description="Voice to use for TTS")
class RegenerateAudioResponse(BaseModel):
"""Response after regenerating audio"""
audio_path: str
duration: float
success: bool = True
class InpaintRequest(BaseModel):
"""Request to inpaint (局部重绘) frame image"""
mask: str = Field(..., description="Base64 encoded mask image (white=inpaint, black=keep)")
prompt: Optional[str] = Field(None, description="Optional prompt for inpainted region")
denoise_strength: float = Field(0.8, ge=0.0, le=1.0, description="Denoise strength (0.0-1.0)")
class InpaintResponse(BaseModel):
"""Response after inpainting"""
image_path: str
success: bool = True