frameforge-v1 / models.py
kajalan's picture
feat: add remote input file downloading and placeholder replacement for FFmpeg commands (#3)
cf22b5c
Raw History Blame Contribute Delete
1.81 kB
from pydantic import BaseModel, HttpUrl, field_validator
from typing import Any, Optional, Literal
class FFmpegCommandRequest(BaseModel):
input_url: str
output_format: str = "mp4"
ffmpeg_args: str = ""
output_filename: Optional[str] = None
@field_validator("output_format")
@classmethod
def validate_format(cls, v: str) -> str:
allowed = {
"mp4", "webm", "mkv", "avi", "mov",
"mp3", "aac", "flac", "wav", "ogg",
"gif", "png", "jpg", "jpeg", "webp"
}
if v not in allowed:
raise ValueError(f"Format '{v}' not allowed. Allowed: {', '.join(sorted(allowed))}")
return v
class FFprobeRequest(BaseModel):
input_url: str
class RendiFFmpegRequest(BaseModel):
input_files: dict[str, str]
output_files: dict[str, str]
ffmpeg_command: str
class ProgressInfo(BaseModel):
percent: float = 0.0
speed: str = ""
fps: str = ""
time_elapsed: float = 0.0
bitrate: str = ""
frame: int = 0
class JobResponse(BaseModel):
job_id: str
status: Literal["pending", "queued", "running", "done", "failed"]
progress: ProgressInfo = ProgressInfo()
download_url: Optional[str] = None
error: Optional[str] = None
age_seconds: Optional[float] = None
class ResourceInfo(BaseModel):
cpu_count: int
cpu_percent: float
ram_total_gb: float
ram_used_gb: float
ram_free_gb: float
ram_percent: float
tmp_free_gb: float
active_jobs: int
queued_jobs: int
max_concurrent: int
ffmpeg_threads: int
class HealthResponse(BaseModel):
status: str
service: str
version: str = ""
ffmpeg_version: str = ""
hw_accel: str = "none"
max_concurrent: int = 4
ffmpeg_threads: int = 2
max_upload_gb: float = 0.5