feat(US3+4): video frame extraction + video-to-text — POST /api/v1/video/*

- app/models/video_models.py: ExtractFramesRequest, VideoToTextRequest,
  FrameInfo, VideoJobCallback, VideoAcceptedResponse
- app/services/video_service.py: interval+keyframe frame extraction,
  uniform-sample video-to-text, HTTP callback, temp file cleanup
- app/routers/video.py: size check helper (_check_video_size via head_object),
  BackgroundTasks enqueue for both endpoints
- tests: 6 service + 4 router tests, 10/10 passing
This commit is contained in:
wh
2026-04-10 16:00:08 +08:00
parent 2876c179ac
commit 0274bb470a
10 changed files with 560 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
from pydantic import BaseModel
class ExtractFramesRequest(BaseModel):
file_path: str
source_id: int
job_id: int
mode: str = "interval"
frame_interval: int = 30
class VideoToTextRequest(BaseModel):
file_path: str
source_id: int
job_id: int
start_sec: float
end_sec: float
model: str | None = None
prompt_template: str | None = None
class FrameInfo(BaseModel):
frame_index: int
time_sec: float
frame_path: str
class VideoJobCallback(BaseModel):
job_id: int
status: str
frames: list[FrameInfo] | None = None
output_path: str | None = None
error_message: str | None = None
class VideoAcceptedResponse(BaseModel):
message: str
job_id: int