File size: 1,958 Bytes
0da2d0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from pydantic import BaseModel, Field
from typing import Optional, List
from enum import Enum


class HighlightStyle(str, Enum):
    DYNAMIC = "dynamic"
    BROADCAST = "broadcast"
    GOALS_ONLY = "goals_only"
    TACTICAL = "tactical"


class OutputQuality(str, Enum):
    Q480 = "480p"
    Q720 = "720p"
    Q1080 = "1080p"


QUALITY_MAP = {"480p": (854, 480), "720p": (1280, 720), "1080p": (1920, 1080)}


class ProcessRequest(BaseModel):
    video_url: str = Field(..., description="URL (YouTube/direct/local path) of the match video")
    highlight_duration: int = Field(10, ge=3, le=20, description="Desired highlight duration in minutes")
    style: HighlightStyle = HighlightStyle.DYNAMIC
    output_quality: OutputQuality = OutputQuality.Q720
    team_home: Optional[str] = None
    team_away: Optional[str] = None
    match_date: Optional[str] = None
    fast_mode: bool = Field(False, description="Audio-only analysis (no GPU needed, ~80% quality)")
    frame_sample_rate: int = Field(5, ge=1, le=30, description="Analyze every Nth frame")
    pre_buffer: float = Field(3.0, description="Seconds before event")
    post_buffer: float = Field(5.0, description="Seconds after event")
    fade_duration: float = Field(0.5, description="Fade transition duration")


class SoccerEvent(BaseModel):
    timestamp: float
    event_type: str
    confidence: float = 0.0
    description: str = ""


class ScoredEvent(BaseModel):
    event: SoccerEvent
    score: float
    chunk_index: int = 0


class ClipSegment(BaseModel):
    start: float
    end: float
    score: float
    events: List[ScoredEvent] = []


class JobStatus(BaseModel):
    job_id: str
    status: str = "queued"
    progress: float = 0.0
    stage: str = ""
    message: str = ""
    result: Optional[dict] = None


class ChunkAnalysis(BaseModel):
    chunk_index: int
    start_time: float
    end_time: float
    events: List[ScoredEvent] = []
    audio_excitement: List[tuple] = []