feat: Add comprehensive timeline editor with frame editing and regeneration capabilities
This commit is contained in:
110
api/schemas/editor.py
Normal file
110
api/schemas/editor.py
Normal file
@@ -0,0 +1,110 @@
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user