File size: 1,063 Bytes
851e5ba | 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 | """Task-specific clip length presets shared by selection and rendering."""
from dataclasses import dataclass
from typing import Any
@dataclass(frozen=True)
class ClipDuration:
minimum: int
maximum: int
ideal_minimum: int
ideal_maximum: int
CLIP_DURATIONS = {
"auto": ClipDuration(15, 60, 25, 50),
# Ideal maxima leave room for the sentence rewind/extension before the cap.
"short": ClipDuration(15, 30, 18, 25),
"medium": ClipDuration(30, 60, 35, 55),
"long": ClipDuration(60, 120, 75, 110),
}
def validate_clip_length(value: Any) -> str:
if not isinstance(value, str) or value not in CLIP_DURATIONS:
raise ValueError("clip_length must be auto, short, medium, or long")
return value
def normalize_clip_length(value: Any) -> str:
"""Stored task settings fall back to Auto instead of failing the job."""
return value if isinstance(value, str) and value in CLIP_DURATIONS else "auto"
def clip_duration(value: str = "auto") -> ClipDuration:
return CLIP_DURATIONS[validate_clip_length(value)]
|