feat: append source clip name to annotated output filename

Output was a fixed name (merged_annotated.mp4) so every download looked
the same. The source clip name is now appended at the back:
merged_annotated_rekap_2026-10-27.mp4

- src/naming.py: annotated_output_name() + source_stem(); client upload
  name wins, stored file name is the fallback (reuse endpoint), unsafe
  chars replaced, stem capped at 80 chars
- src/job.py: Job.source_stem + add_job(source_stem=...); both output
  paths go through the helper
- app.py: capture the sanitized client filename before the collision
  suffix is added
- cli.py: same helper for the CLI output name

Verified live on .93: POST /api/analyze with 'rekap 2026-10-27.mp4' ->
output/job-e0409b05/merged_annotated_rekap_2026-10-27.mp4, download 200.
This commit is contained in:
jetson committed 2026-10-27 11:26:07 +07:00
1 parent dbaa87c4e8
commit e963ba0cb4
6 files changed
+174 -4

No files matched your search

+5 -1
View File
@@ -7,6 +7,7 @@ import os
import sys
from src.model_registry import ModelConfig, scan_models
from src.naming import annotated_output_name
from src.pipeline import run_pipeline
@@ -96,7 +97,10 @@ def main(argv: list[str] | None = None) -> None:
if args.output and len(selected) == 1:
out_path = args.output
else:
out_path = os.path.join(args.output_dir, f"{model_cfg.stem}_annotated.mp4")
out_path = os.path.join(
args.output_dir,
annotated_output_name(f"{model_cfg.stem}_annotated", args.video),
)
parent = os.path.dirname(out_path)
if parent:
os.makedirs(parent, exist_ok=True)