feat: Add comprehensive timeline editor with frame editing and regeneration capabilities

This commit is contained in:
empty
2026-01-05 14:48:43 +08:00
parent 7d78dcd078
commit ca018a9b1f
68 changed files with 14904 additions and 57 deletions

110
api/schemas/editor.py Normal file
View 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

81
api/schemas/publish.py Normal file
View File

@@ -0,0 +1,81 @@
# 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.
"""
Publish API schemas
"""
from pydantic import BaseModel, Field
from typing import List, Optional, Dict, Any
from enum import Enum
class PlatformEnum(str, Enum):
export = "export"
bilibili = "bilibili"
youtube = "youtube"
class PublishStatusEnum(str, Enum):
pending = "pending"
converting = "converting"
uploading = "uploading"
processing = "processing"
published = "published"
failed = "failed"
class VideoMetadataSchema(BaseModel):
"""Video metadata for publishing"""
title: str = Field(..., min_length=1, max_length=100)
description: str = Field("", max_length=5000)
tags: List[str] = Field(default_factory=list)
category: Optional[str] = None
cover_path: Optional[str] = None
privacy: str = Field("public", pattern="^(public|private|unlisted)$")
platform_options: Dict[str, Any] = Field(default_factory=dict)
class PublishRequest(BaseModel):
"""Request to publish a video"""
video_path: str = Field(..., description="Path to the video file")
metadata: VideoMetadataSchema
class PublishResultSchema(BaseModel):
"""Result of a publishing operation"""
success: bool
platform: str
status: PublishStatusEnum
video_url: Optional[str] = None
platform_video_id: Optional[str] = None
error_message: Optional[str] = None
export_path: Optional[str] = None
class PublishTaskSchema(BaseModel):
"""A publishing task"""
id: str
platform: str
status: PublishStatusEnum
result: Optional[PublishResultSchema] = None
created_at: str
updated_at: Optional[str] = None
class PlatformRequirementsSchema(BaseModel):
"""Platform requirements"""
max_file_size_mb: int
max_duration_seconds: Optional[int] = None
supported_formats: List[str] = []
recommended_resolution: tuple = (1080, 1920)
recommended_codec: str = "h264"