From 5dedc3024f232332f537c4769fa173f12741e4c6 Mon Sep 17 00:00:00 2001 From: SystemZion Date: Sun, 2 Aug 2026 12:35:23 +0800 Subject: [PATCH] Build the FACUT 0.4 travel workflow --- .gitignore | 1 + README.md | 35 +++++- pyproject.toml | 2 +- src/facut/__init__.py | 2 +- src/facut/analysis/__init__.py | 2 + src/facut/analysis/travel.py | 132 +++++++++++++++++++++ src/facut/cli/analyze_commands.py | 79 ++++++++++++- src/facut/cli/delivery_commands.py | 125 ++++++++++++++++++++ src/facut/cli/ingest_commands.py | 141 ++++++++++++++++++++++ src/facut/cli/main.py | 8 ++ src/facut/cli/render_commands.py | 26 ++-- src/facut/cli/sequence_commands.py | 9 +- src/facut/cli/subtitle_commands.py | 89 +++++--------- src/facut/core/models.py | 12 ++ src/facut/media/probe.py | 96 ++++++++++++++- src/facut/render/ffmpeg_backend.py | 26 ++++ src/facut/render/incremental.py | 25 ++++ src/facut/render/presets.py | 135 +++++++++++++++++++++ src/facut/schemas/project.schema.json | 141 ++++++++++++++++++++++ src/facut/subtitles/compiler.py | 145 ++++++++++++++++++++++- src/facut/subtitles/editor.py | 6 + src/facut/subtitles/templates.py | 164 ++++++++++++++++++++++++++ tests/test_ingest_cli.py | 31 +++++ tests/test_media_probe.py | 39 +++++- tests/test_render_presets.py | 22 ++++ tests/test_subtitle_cli.py | 25 ++++ tests/test_subtitle_editor.py | 23 ++++ tests/test_travel_analysis.py | 36 ++++++ vendor/ffmpeg/README.md | 15 +++ 29 files changed, 1509 insertions(+), 83 deletions(-) create mode 100644 src/facut/analysis/travel.py create mode 100644 src/facut/cli/delivery_commands.py create mode 100644 src/facut/cli/ingest_commands.py create mode 100644 src/facut/render/presets.py create mode 100644 src/facut/subtitles/templates.py create mode 100644 tests/test_ingest_cli.py create mode 100644 tests/test_render_presets.py create mode 100644 tests/test_travel_analysis.py diff --git a/.gitignore b/.gitignore index dd5e415..2ad6769 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ venv/ /previews/ /renders/ /history/ +/artifacts/ # Editors and operating systems .idea/ diff --git a/README.md b/README.md index d719f8d..af11637 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ **facut**(Fast AI Cut)是一款面向 AI Agent、自动化脚本与高级用户的非破坏性命令行视频编辑器。它使用稳定素材 ID、结构化工程、可组合子命令及统一 JSON 返回值,让复杂剪辑既能由人操作,也能可靠地被程序调用。 -当前版本 `0.3.0` 已打通代理—精剪—声音—QC—多版本交付链路:原片/代理自动切换、片段级增量缓存、多视频轨合成、画面变换与停帧、完整音频处理、JSONL 渲染进度、自动 QC、素材分析、标记、命名序列、字幕模板及常驻 JSON-RPC 会话。Windows 单文件发行版内置 FFmpeg/FFprobe,不依赖系统 Python。 +当前版本 `0.4.0` 在代理—精剪—声音—QC 链路上增加专业旅拍底座:混合设备摄取、相机/GPS/时区/HDR 元数据、内容哈希分析缓存、带证据和置信度的保守分类、单主序列多平台交付,以及从“临港两日”成片提炼的电影感中英双层标题模板。Windows 单文件发行版内置 FFmpeg/FFprobe,不依赖系统 Python。 ## 安装 @@ -40,11 +40,11 @@ facut doctor 当前可执行的公共接口: ```text -facut init/import/inspect/help +facut init/import/ingest/inspect/help facut timeline/clip/transition/effect/audio facut proxy/analyze/qc/marker facut subtitle/text -facut preview/render/sequence +facut preview/render/deliver/delivery-presets/sequence facut project/history facut undo/redo/run/serve/doctor ``` @@ -150,6 +150,18 @@ facut --project demo serve 它通过 stdin/stdout 交换逐行 JSON-RPC,支持 `ping`、`project.snapshot`、`timeline.show`、原子 `run` 和 `shutdown`,同一进程复用已载入工程。 +## 专业旅拍摄取与素材理解 + +```powershell +facut ingest D:\JapanTrip --trip "日本旅行2026" --verify sha256 --proxy auto +facut --project 日本旅行2026 inspect --json +facut --project 日本旅行2026 analyze travel --save --json +``` + +`ingest` 递归导入手机、相机、运动相机、无人机、录音与字幕素材,逐文件流式计算 SHA-256,并可先查找同名/LRF 代理、缺失时生成 540p 代理。默认新建 3840×2160、48kHz 工程;也可配合全局 `--project` 写入已有工程。 + +FFprobe 元数据会保留旋转、VFR、创建时间、时区、时间码、相机厂商/型号、镜头、GPS、色彩空间和 HDR-PQ/HDR-HLG/Log 线索。`analyze travel` 第一版只根据路径和元数据产生可解释候选,每项含 `confidence` 与 `evidence`;文件夹名并不被当作画面事实。需要人物、动作、地点或镜头语义时会明确返回 `plugin_required`。同一内容哈希和参数的分析结果写入工程缓存,后续调用直接复用。 + ## 完整可运行示例 裁切并合并: @@ -182,11 +194,13 @@ facut --project demo subtitle import captions.srt --track S1 facut --project demo subtitle shift S1 --offset +500ms facut --project demo subtitle export S1 --format vtt --output captions.vtt facut --project demo text add --text "临港两日" --at 1s --duration 3s --y 20% +facut --project demo text add --text "抬头,是更大的尺度" --subtitle "LOOK UP · THE SCALE CHANGES" --at 4s --duration 3s --template lingang-cinematic-panel +facut --project demo text add --text "再来" --subtitle "同一条雪道,重新滑下" --at 48s --duration 2s --template lingang-cinematic-mint facut --project demo subtitle compile-ass --output render-text.ass facut --project demo render --output subtitled.mp4 ``` -渲染和预览会自动将工程中的字幕与文字编译为临时 ASS 并烧录。`compile-ass` 仍可生成独立、可检查的 ASS 侧车文件。 +渲染和预览会自动将工程中的字幕与文字编译为临时 ASS 并烧录。`compile-ass` 仍可生成独立、可检查的 ASS 侧车文件。临港系列模板不是简单的颜色预设:编译器会生成半透明圆角矢量面板、细描边、强调色竖线和独立主副标题图层,并按 1080p/4K 画布等比例缩放。内置 `lingang-cinematic-panel`、`lingang-cinematic-mint`、`lingang-cinematic-warm`、`lingang-day-card` 和 `lingang-main-title`;可用 `--accent-color` 覆盖强调色。软件不捆绑第三方字体文件,默认使用系统字体以避免授权问题。 背景音乐与原声混合: @@ -241,7 +255,16 @@ facut text presets facut --project demo text import-csv titles.csv --template documentary-lower-third ``` -命名 sequence 保存时间线快照并共享素材/代理池,可在一个工程维护主片、精华版等交付版本。文字内置纪录片下三分之一、章节、歌曲标题和字幕底板模板,并支持阴影、半透明底、安全区、对齐和字距。 +命名 sequence 保存时间线快照并共享素材/代理池,可在一个工程维护主片、精华版等交付版本。文字模板支持阴影、半透明底、安全区、对齐、字距和模板专属矢量图层。 + +一个主序列可一次生成横版、竖版与方形派生文件: + +```bash +facut delivery-presets --json +facut --project demo deliver --preset youtube-4k-sdr --also bilibili-4k,shorts-9x16,community-1x1 --output-dir renders/delivery --hardware auto +``` + +YouTube 预设保留工程原帧率,标准帧率 4K SDR 使用 45Mbps、高帧率使用 68Mbps,输出 AAC 384kbps、BT.709、4:2:0 和 MP4 Fast Start。B站预设明确标记为 FACUT 创作者工作流默认值,不伪称平台官方上限。竖版输出当前使用确定性画面适配并发出警告;主体跟踪式自动重构图尚未实现。 ### 当前明确限制 @@ -250,6 +273,8 @@ facut --project demo text import-csv titles.csv --template documentary-lower-thi - 调整层当前接受单 FFmpeg 节点效果;像素化这种多节点效果暂不接受。 - 画面关键帧当前为线性 x/y/scale/rotation;光流补帧和高级稳定模型尚未实现。 - ASR 需要用户提供本地模型;歌曲识别需要本地指纹数据库插件。 +- 旅拍语义分类目前以元数据/路径规则为确定性底座;视觉语义搜索、人物识别、故事生成和 B-roll 覆盖诊断仍需后续本地视觉索引插件。 +- GPX/KML 路线动画、主体跟踪自动重构图、OpenTimelineIO/FCPXML 交换尚未实现。 - 增量缓存会对复杂工程安全降级为整片渲染;跨转场区间复用是后续优化。 ## 开发与测试 diff --git a/pyproject.toml b/pyproject.toml index c8f3a3d..119e845 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "facut" -version = "0.3.0" +version = "0.4.0" description = "Fast AI Cut — a deterministic, agent-friendly command-line video editor" readme = "README.md" requires-python = ">=3.11" diff --git a/src/facut/__init__.py b/src/facut/__init__.py index 9548529..89d1f26 100644 --- a/src/facut/__init__.py +++ b/src/facut/__init__.py @@ -4,4 +4,4 @@ __all__ = ["__version__"] -__version__ = "0.3.0" +__version__ = "0.4.0" diff --git a/src/facut/analysis/__init__.py b/src/facut/analysis/__init__.py index a558d84..04ffd30 100644 --- a/src/facut/analysis/__init__.py +++ b/src/facut/analysis/__init__.py @@ -7,11 +7,13 @@ analyze_song_metadata, transcribe_local, ) +from .travel import analyze_travel_metadata __all__ = [ "analyze_beats", "analyze_quality", "analyze_scenes", "analyze_song_metadata", + "analyze_travel_metadata", "transcribe_local", ] diff --git a/src/facut/analysis/travel.py b/src/facut/analysis/travel.py new file mode 100644 index 0000000..22e8c9c --- /dev/null +++ b/src/facut/analysis/travel.py @@ -0,0 +1,132 @@ +"""Explainable, conservative travel-footage classification primitives.""" + +from __future__ import annotations + +from datetime import datetime +from pathlib import Path +from typing import Any + +from facut.core.models import MediaTechnicalInfo + + +_TOKENS: dict[str, tuple[str, ...]] = { + "city": ("city", "城市", "街道", "street", "downtown"), + "attraction": ("景点", "museum", "博物馆", "天文馆", "temple", "古城"), + "transport": ("airport", "机场", "train", "高铁", "地铁", "drive", "自驾"), + "hotel": ("hotel", "酒店", "民宿", "room"), + "food": ("food", "美食", "餐厅", "restaurant", "早餐", "晚餐"), + "snow-sports": ("滑雪", "ski", "snowboard", "雪场"), + "aerial": ("drone", "航拍", "无人机", "dji mavic"), + "timelapse": ("timelapse", "time-lapse", "延时"), + "a-roll": ("口播", "talking", "interview", "旁白"), + "detail": ("detail", "细节", "特写", "closeup", "close-up"), +} + + +def analyze_travel_metadata( + path: str | Path, technical: MediaTechnicalInfo +) -> dict[str, Any]: + """Return evidence-backed candidates without claiming visual recognition.""" + + source = Path(path).expanduser().resolve() + searchable = " ".join((source.name, *source.parts[-4:])).casefold() + searchable = searchable.replace("_", " ").replace("-", " ") + candidates: list[dict[str, Any]] = [] + for label, tokens in _TOKENS.items(): + matched = sorted({token for token in tokens if token.casefold() in searchable}) + if matched: + candidates.append( + { + "dimension": "travel_category", + "label": label, + "confidence": 0.68, + "evidence": [{"type": "path_token", "value": item} for item in matched], + } + ) + + device = _device_candidate(technical) + if device: + candidates.append(device) + daypart = _daypart_candidate(technical.creation_time, technical.timezone_offset) + if daypart: + candidates.append(daypart) + if technical.dynamic_range != "unknown": + candidates.append( + { + "dimension": "dynamic_range", + "label": technical.dynamic_range, + "confidence": 0.98, + "evidence": [ + {"type": "ffprobe", "field": "color_transfer", "value": technical.color_transfer} + ], + } + ) + return { + "source": str(source), + "method": "metadata-and-path-rules-v1", + "candidates": candidates, + "visual_semantics": { + "status": "plugin_required", + "limitation": "Scene meaning, people, actions, reactions and shot quality require a configured vision analyzer.", + }, + "uncertainties": [ + "Path-token labels describe user organization and are not proof of frame contents." + ], + } + + +def _device_candidate(technical: MediaTechnicalInfo) -> dict[str, Any] | None: + description = " ".join( + item for item in (technical.camera_make, technical.camera_model) if item + ) + normalized = description.casefold() + if not normalized: + return None + if any(token in normalized for token in ("mavic", "phantom", "inspire")): + label, confidence = "drone", 0.94 + elif any(token in normalized for token in ("gopro", "insta360", "osmo action")): + label, confidence = "action-camera", 0.94 + elif any(token in normalized for token in ("iphone", "pixel", "huawei", "xiaomi", "oppo", "vivo")): + label, confidence = "phone", 0.90 + else: + label, confidence = "camera", 0.72 + return { + "dimension": "capture_device", + "label": label, + "confidence": confidence, + "evidence": [{"type": "camera_metadata", "value": description}], + } + + +def _daypart_candidate( + creation_time: str | None, timezone_offset: str | None +) -> dict[str, Any] | None: + if not creation_time: + return None + try: + parsed = datetime.fromisoformat(creation_time.replace("Z", "+00:00")) + except ValueError: + return None + hour = parsed.hour + if 5 <= hour < 8: + label = "sunrise-window" + elif 8 <= hour < 17: + label = "day" + elif 17 <= hour < 20: + label = "sunset-window" + else: + label = "night" + reliable_timezone = parsed.tzinfo is not None or timezone_offset is not None + return { + "dimension": "daypart", + "label": label, + "confidence": 0.86 if reliable_timezone else 0.52, + "evidence": [ + { + "type": "creation_time", + "value": creation_time, + "timezone_offset": timezone_offset, + } + ], + "warning": None if reliable_timezone else "Timezone is missing; local daypart may be wrong.", + } diff --git a/src/facut/cli/analyze_commands.py b/src/facut/cli/analyze_commands.py index 20f1d5b..52dbe3a 100644 --- a/src/facut/cli/analyze_commands.py +++ b/src/facut/cli/analyze_commands.py @@ -3,6 +3,9 @@ from __future__ import annotations import json +import hashlib +import os +import tempfile from pathlib import Path from typing import Annotated, Any, Callable @@ -13,13 +16,17 @@ analyze_quality, analyze_scenes, analyze_song_metadata, + analyze_travel_metadata, transcribe_local, ) from facut.cli.common import manager_for, public_error from facut.responses import success_response +from facut.media.probe import probe_media -analyze_app = typer.Typer(help="Analyze quality, scenes, beats, speech, and song metadata.") +analyze_app = typer.Typer( + help="Analyze quality, scenes, beats, speech, travel metadata, and song metadata." +) def _state(ctx: typer.Context): @@ -53,12 +60,53 @@ def _emit_analysis( analyzer: Callable[[Path], dict[str, Any]], *, save: bool, + cache_parameters: dict[str, Any] | None = None, ) -> None: from facut.cli.main import emit try: path, media_id, manager = _resolve(ctx, target) - result = analyzer(path) + cache_key = None + cache_path = None + cache_hit = False + if media_id is not None and manager is not None: + asset = manager.require_document().find_media(media_id) + assert asset is not None + encoded = json.dumps( + { + "analysis": command, + "algorithm_version": 1, + "media_sha256": asset.sha256, + "parameters": cache_parameters or {}, + }, + sort_keys=True, + separators=(",", ":"), + ).encode("utf-8") + cache_key = hashlib.sha256(encoded).hexdigest() + cache_path = manager.project_dir / "cache" / "analysis" / f"{cache_key}.json" + if cache_path is not None and cache_path.is_file(): + result = json.loads(cache_path.read_text(encoding="utf-8")) + cache_hit = True + else: + result = analyzer(path) + if cache_path is not None: + cache_path.parent.mkdir(parents=True, exist_ok=True) + with tempfile.NamedTemporaryFile( + mode="w", + encoding="utf-8", + dir=cache_path.parent, + prefix=f".{cache_key}-", + suffix=".tmp", + delete=False, + ) as stream: + json.dump(result, stream, ensure_ascii=False, indent=2) + stream.write("\n") + temporary = Path(stream.name) + os.replace(temporary, cache_path) + result = { + **result, + "cache": {"hit": cache_hit, "key": cache_key}, + } revision = None if save: if media_id is None or manager is None: @@ -101,6 +149,7 @@ def scenes( target, lambda path: analyze_scenes(path, threshold=threshold, ffmpeg=state.config.tools.ffmpeg), save=save, + cache_parameters={"threshold": threshold}, ) @@ -121,6 +170,7 @@ def quality( ffprobe=state.config.tools.ffprobe, ), save=save, + cache_parameters={}, ) @@ -137,6 +187,7 @@ def beats( target, lambda path: analyze_beats(path, ffmpeg=state.config.tools.ffmpeg), save=save, + cache_parameters={}, ) @@ -154,6 +205,7 @@ def transcript( target, lambda path: transcribe_local(path, model_path=model, language=language), save=save, + cache_parameters={"model": str(model), "language": language}, ) @@ -170,4 +222,27 @@ def song( target, lambda path: analyze_song_metadata(path, ffprobe=state.config.tools.ffprobe), save=save, + cache_parameters={}, + ) + + +@analyze_app.command("travel") +def travel( + ctx: typer.Context, + target: str, + save: Annotated[bool, typer.Option("--save")] = False, +) -> None: + """Classify travel metadata conservatively and expose missing vision capability.""" + + state = _state(ctx) + _emit_analysis( + ctx, + "analyze.travel", + target, + lambda path: analyze_travel_metadata( + path, + probe_media(path, ffprobe=state.config.tools.ffprobe), + ), + save=save, + cache_parameters={}, ) diff --git a/src/facut/cli/delivery_commands.py b/src/facut/cli/delivery_commands.py new file mode 100644 index 0000000..3208728 --- /dev/null +++ b/src/facut/cli/delivery_commands.py @@ -0,0 +1,125 @@ +"""One-sequence, multi-platform deterministic delivery.""" + +from __future__ import annotations + +import json +import re +from pathlib import Path +from typing import Annotated + +import typer + +from facut.cli.common import manager_for, public_error +from facut.core.sequences import materialize_sequence +from facut.render import FFmpegBackend +from facut.render.presets import ( + RENDER_PRESETS, + list_render_presets, + resolve_render_preset, +) +from facut.responses import success_response + + +def _state(ctx: typer.Context): + from facut.cli.main import CliState + + return ctx.ensure_object(CliState) + + +def delivery_presets_command(ctx: typer.Context) -> None: + """List machine-readable delivery presets and their provenance.""" + + from facut.cli.main import emit + + data = list_render_presets() + emit( + _state(ctx), + success_response("delivery-presets", data), + human=json.dumps(data, ensure_ascii=False, indent=2), + ) + + +def deliver_command( + ctx: typer.Context, + output_dir: Annotated[Path, typer.Option("--output-dir")], + preset: Annotated[str, typer.Option("--preset")] = "youtube-4k-sdr", + also: Annotated[ + str | None, + typer.Option("--also", help="Comma-separated additional presets."), + ] = None, + basename: Annotated[str | None, typer.Option("--basename")] = None, + sequence: Annotated[str | None, typer.Option("--sequence")] = None, + subtitles: Annotated[ + str, typer.Option("--subtitles", help="burn or none.") + ] = "burn", + hardware: Annotated[str, typer.Option("--hardware")] = "auto", + overwrite: Annotated[bool, typer.Option("--overwrite")] = False, +) -> None: + """Render a master sequence into several platform derivatives.""" + + from facut.cli.main import emit, fail + + command = "deliver" + state = _state(ctx) + try: + if subtitles not in {"burn", "none"}: + raise ValueError("--subtitles must be burn or none.") + manager = manager_for(state) + document = manager.require_document() + if sequence: + document = materialize_sequence(document, sequence) + if subtitles == "none": + document = document.model_copy(deep=True) + document.subtitle_cues = [] + document.text_overlays = [] + names = [preset] + if also: + names.extend(item.strip() for item in also.split(",") if item.strip()) + names = list(dict.fromkeys(names)) + unknown = [name for name in names if name not in RENDER_PRESETS] + if unknown: + raise ValueError(f'Unknown delivery preset(s): {", ".join(unknown)}.') + safe_base = basename or sequence or document.project.name + safe_base = re.sub(r"[^\w.-]+", "-", safe_base, flags=re.UNICODE).strip("-.") + safe_base = safe_base or "facut-delivery" + output_dir.mkdir(parents=True, exist_ok=True) + backend = FFmpegBackend(state.config.tools.ffmpeg) + results = [] + warnings: list[str] = [] + for name in names: + settings = resolve_render_preset(name, source_fps=document.project.fps) + destination = output_dir / f"{safe_base}-{name}.mp4" + result = backend.render( + document, + manager.project_dir, + destination, + width=settings["width"], + height=settings["height"], + fps=settings["fps"], + bitrate=settings["bitrate"], + audio_bitrate=settings["audio_bitrate"], + audio_sample_rate=settings["audio_sample_rate"], + color_space=settings.get("color_space"), + hardware=hardware, + overwrite=overwrite, + ) + results.append( + {"preset": name, "settings": settings, **result.as_dict()} + ) + warnings.extend(result.warnings) + if settings["width"] < settings["height"]: + warnings.append( + f"{name}: vertical output uses deterministic clip fit; subject-aware auto reframe is not yet applied." + ) + emit( + state, + success_response( + command, + {"deliveries": results, "subtitles": subtitles}, + warnings=list(dict.fromkeys(warnings)), + project_revision=document.revision, + ), + human=json.dumps(results, ensure_ascii=False, indent=2), + ) + except Exception as error: + fail(state, command, public_error(error)) diff --git a/src/facut/cli/ingest_commands.py b/src/facut/cli/ingest_commands.py new file mode 100644 index 0000000..945e2a3 --- /dev/null +++ b/src/facut/cli/ingest_commands.py @@ -0,0 +1,141 @@ +"""High-level mixed-device travel ingestion workflow.""" + +from __future__ import annotations + +import json +import re +from pathlib import Path +from typing import Annotated + +import typer + +from facut.cli.common import public_error +from facut.core.models import MediaKind +from facut.core.project_manager import ProjectManager +from facut.media.proxy_manager import ProxyError, ProxyManager +from facut.responses import success_response + + +def _state(ctx: typer.Context): + from facut.cli.main import CliState + + return ctx.ensure_object(CliState) + + +def _project_slug(name: str) -> str: + cleaned = re.sub(r"[^\w.-]+", "-", name, flags=re.UNICODE).strip("-.") + return cleaned or "facut-trip" + + +def ingest_command( + ctx: typer.Context, + source: Annotated[Path, typer.Argument(help="Travel media root directory.")], + trip: Annotated[str, typer.Option("--trip", help="Human-readable trip name.")], + output: Annotated[ + Path | None, + typer.Option("--output", help="New project directory when --project is absent."), + ] = None, + verify: Annotated[str, typer.Option("--verify")] = "sha256", + proxy: Annotated[ + str, + typer.Option("--proxy", help="none, link, or auto (link then create)."), + ] = "none", + proxy_height: Annotated[int, typer.Option("--proxy-height")] = 540, + dry_run: Annotated[bool, typer.Option("--dry-run")] = False, +) -> None: + """Import a mixed-device trip, verify content hashes, and manage proxies.""" + + from facut.cli.main import emit, fail + + command = "ingest" + state = _state(ctx) + try: + source = source.expanduser().resolve() + if not source.is_dir(): + raise FileNotFoundError(f'Ingest root "{source}" was not found.') + if verify.casefold() != "sha256": + raise ValueError("The first release supports --verify sha256 only.") + proxy_mode = proxy.casefold() + if proxy_mode not in {"none", "link", "auto"}: + raise ValueError("--proxy must be none, link, or auto.") + if state.project is not None: + manager = ProjectManager(state.project) + manager.load() + else: + destination = (output or Path.cwd() / _project_slug(trip)).resolve() + if dry_run: + raise ValueError( + "--dry-run requires an existing --project because project creation is not simulated." + ) + manager = ProjectManager.create( + destination, + name=trip, + width=3840, + height=2160, + fps=30.0, + sample_rate=48000, + ) + assets = manager.import_paths([source], recursive=True, dry_run=dry_run) + if not dry_run: + def record_trip(document): + document.settings["trip"] = { + "name": trip, + "source_root": manager.store_path(source), + "verification": "sha256", + } + return document.settings["trip"] + + manager.mutate( + "ingest.metadata", + f"Recorded trip metadata for {trip}", + record_trip, + command={"trip": trip, "verify": verify}, + ) + proxy_results: list[dict[str, object]] = [] + if proxy_mode != "none" and not dry_run: + service = ProxyManager( + manager, + ffmpeg=state.config.tools.ffmpeg, + ffprobe=state.config.tools.ffprobe, + ) + for asset in assets: + if asset.kind != MediaKind.VIDEO: + continue + try: + linked, _, matched = service.relink(asset.id, source) + proxy_results.append( + {"media_id": asset.id, "status": "linked", "path": str(matched)} + ) + del linked + except (FileNotFoundError, ProxyError): + if proxy_mode == "link": + proxy_results.append( + {"media_id": asset.id, "status": "not_found", "path": None} + ) + continue + _, _, generated = service.create( + asset.id, height=proxy_height, codec="h264", overwrite=False + ) + proxy_results.append( + {"media_id": asset.id, "status": "created", "path": str(generated)} + ) + document = manager.require_document() + data = { + "project": str(manager.project_file.resolve()), + "trip": trip, + "verification": { + "algorithm": "sha256", + "verified": not dry_run, + "asset_count": len(assets), + }, + "media": [asset.model_dump(mode="json") for asset in assets], + "proxies": proxy_results, + "dry_run": dry_run, + } + emit( + state, + success_response(command, data, project_revision=document.revision), + human=json.dumps(data, ensure_ascii=False, indent=2), + ) + except Exception as error: + fail(state, command, public_error(error)) diff --git a/src/facut/cli/main.py b/src/facut/cli/main.py index a1e7ffd..b6c4e82 100644 --- a/src/facut/cli/main.py +++ b/src/facut/cli/main.py @@ -213,9 +213,15 @@ def main() -> None: from facut.cli.sequence_commands import sequence_app # noqa: E402 from facut.cli.serve_commands import serve_command # noqa: E402 from facut.cli.effect_commands import effect_app # noqa: E402 +from facut.cli.ingest_commands import ingest_command # noqa: E402 +from facut.cli.delivery_commands import ( # noqa: E402 + deliver_command, + delivery_presets_command, +) app.command("init")(init_command) app.command("import")(import_command) +app.command("ingest")(ingest_command) app.command("inspect")(inspect_command) app.command("undo")(undo_command) app.command("redo")(redo_command) @@ -236,6 +242,8 @@ def main() -> None: app.add_typer(analyze_app, name="analyze") app.add_typer(sequence_app, name="sequence") app.command("serve")(serve_command) +app.command("deliver")(deliver_command) +app.command("delivery-presets")(delivery_presets_command) app.add_typer(effect_app, name="effect") diff --git a/src/facut/cli/render_commands.py b/src/facut/cli/render_commands.py index 37c34d1..e3270a6 100644 --- a/src/facut/cli/render_commands.py +++ b/src/facut/cli/render_commands.py @@ -14,19 +14,12 @@ from facut.core.timeline_engine import parse_time from facut.render import FFmpegBackend from facut.render.incremental import IncrementalRenderer, incremental_eligibility +from facut.render.presets import RENDER_PRESETS, resolve_render_preset from facut.responses import success_response preview_app = typer.Typer(help="Render fast low-resolution timeline previews.") -RENDER_PRESETS: dict[str, dict[str, Any]] = { - "youtube-1080p": {"width": 1920, "height": 1080, "fps": 30.0, "bitrate": "12M"}, - "youtube-4k": {"width": 3840, "height": 2160, "fps": 30.0, "bitrate": "45M"}, - "bilibili-1080p": {"width": 1920, "height": 1080, "fps": 30.0, "bitrate": "12M"}, - "tiktok-1080x1920": {"width": 1080, "height": 1920, "fps": 30.0, "bitrate": "12M"}, -} - - def _state(ctx: typer.Context): from facut.cli.main import CliState @@ -302,7 +295,7 @@ def render_command( fps: Annotated[float | None, typer.Option("--fps")] = None, bitrate: Annotated[str | None, typer.Option("--bitrate")] = None, audio_codec: Annotated[str, typer.Option("--audio-codec")] = "aac", - audio_bitrate: Annotated[str, typer.Option("--audio-bitrate")] = "320k", + audio_bitrate: Annotated[str | None, typer.Option("--audio-bitrate")] = None, hardware: Annotated[str, typer.Option("--hardware")] = "auto", overwrite: Annotated[bool, typer.Option("--overwrite")] = False, jsonl_progress: Annotated[ @@ -341,11 +334,20 @@ def render_command( raise ValueError( f'Unknown render preset "{preset}". Available: {", ".join(RENDER_PRESETS)}.' ) - settings = RENDER_PRESETS[preset] + settings = resolve_render_preset( + preset, source_fps=document.project.fps, requested_fps=fps + ) width = width or settings["width"] height = height or settings["height"] fps = fps or settings["fps"] bitrate = bitrate or settings["bitrate"] + audio_bitrate = audio_bitrate or settings["audio_bitrate"] + audio_sample_rate = settings["audio_sample_rate"] + color_space = settings.get("color_space") + else: + color_space = None + audio_sample_rate = None + audio_bitrate = audio_bitrate or "320k" backend = FFmpegBackend(state.config.tools.ffmpeg) progress = _progress_callback( state, @@ -369,6 +371,8 @@ def render_command( audio_bitrate=audio_bitrate, bitrate=bitrate, hardware=hardware, + color_space=color_space, + audio_sample_rate=audio_sample_rate, overwrite=overwrite, progress=progress, ) @@ -385,6 +389,8 @@ def render_command( audio_bitrate=audio_bitrate, bitrate=bitrate, hardware=hardware, + color_space=color_space, + audio_sample_rate=audio_sample_rate, overwrite=overwrite, progress=progress, ) diff --git a/src/facut/cli/sequence_commands.py b/src/facut/cli/sequence_commands.py index 5bc7524..bb22d0e 100644 --- a/src/facut/cli/sequence_commands.py +++ b/src/facut/cli/sequence_commands.py @@ -10,7 +10,7 @@ import typer from facut.cli.common import manager_for, public_error -from facut.cli.render_commands import RENDER_PRESETS +from facut.render.presets import RENDER_PRESETS, resolve_render_preset from facut.core.sequences import ( checkout_sequence, duplicate_sequence, @@ -147,7 +147,9 @@ def render_all( document = manager.require_document() if preset not in RENDER_PRESETS: raise ValueError(f'Unknown render preset "{preset}".') - settings = RENDER_PRESETS[preset] + settings = resolve_render_preset( + preset, source_fps=document.project.fps + ) output_dir.mkdir(parents=True, exist_ok=True) backend = FFmpegBackend(state.config.tools.ffmpeg) results = [] @@ -163,6 +165,9 @@ def render_all( height=settings["height"], fps=settings["fps"], bitrate=settings["bitrate"], + audio_bitrate=settings["audio_bitrate"], + audio_sample_rate=settings["audio_sample_rate"], + color_space=settings.get("color_space"), hardware=hardware, overwrite=overwrite, ) diff --git a/src/facut/cli/subtitle_commands.py b/src/facut/cli/subtitle_commands.py index 5b45f88..e7fe2fd 100644 --- a/src/facut/cli/subtitle_commands.py +++ b/src/facut/cli/subtitle_commands.py @@ -23,59 +23,16 @@ shift_track, ) from facut.subtitles.formats import export_srt, export_vtt, parse_subtitle_file +from facut.subtitles.templates import ( + TEXT_TEMPLATES, + list_text_templates, + resolve_text_template, +) subtitle_app = typer.Typer(help="Import, shift, inspect, export, and compile subtitles.") text_app = typer.Typer(help="Add and manage timed free-text overlays.") -TEXT_TEMPLATES: dict[str, dict[str, Any]] = { - "documentary-lower-third": { - "x": "8%", - "y": "82%", - "font_size": 52.0, - "color": "#FFFFFF", - "stroke_color": "#000000", - "stroke_width": 1.5, - "background": "#00000099", - "shadow": 2.0, - "alignment": "left", - "safe_area": True, - }, - "chapter": { - "x": "center", - "y": "center", - "font_size": 84.0, - "color": "#FFFFFF", - "stroke_width": 2.0, - "shadow": 3.0, - "alignment": "center", - "safe_area": True, - }, - "song-title": { - "x": "8%", - "y": "12%", - "font_size": 46.0, - "color": "#FFFFFF", - "stroke_width": 1.0, - "background": "#101820B3", - "shadow": 2.0, - "alignment": "left", - "safe_area": True, - }, - "caption-box": { - "x": "center", - "y": "88%", - "font_size": 48.0, - "color": "#FFFFFF", - "stroke_width": 0.0, - "background": "#000000B3", - "shadow": 0.0, - "alignment": "center", - "safe_area": True, - }, -} - - def _state(ctx: typer.Context): from facut.cli.main import CliState @@ -324,6 +281,9 @@ def text_add( text: Annotated[str, typer.Option("--text")], at: Annotated[str, typer.Option("--at")], duration: Annotated[str, typer.Option("--duration")], + subtitle: Annotated[ + str | None, typer.Option("--subtitle", help="Optional secondary line.") + ] = None, x: Annotated[str | None, typer.Option("--x")] = None, y: Annotated[str | None, typer.Option("--y")] = None, track: Annotated[str | None, typer.Option("--track")] = None, @@ -334,6 +294,9 @@ def text_add( stroke_color: Annotated[str | None, typer.Option("--stroke-color")] = None, stroke_width: Annotated[float | None, typer.Option("--stroke-width")] = None, background: Annotated[str | None, typer.Option("--background")] = None, + accent_color: Annotated[ + str | None, typer.Option("--accent-color", help="Template accent override.") + ] = None, shadow: Annotated[float | None, typer.Option("--shadow")] = None, alignment: Annotated[str | None, typer.Option("--alignment")] = None, letter_spacing: Annotated[ @@ -359,9 +322,13 @@ def text_add( f'Unknown text template "{template}". Available: ' f'{", ".join(TEXT_TEMPLATES)}.' ) - preset = dict(TEXT_TEMPLATES.get(template or "", {})) - resolved_x = x or str(preset.pop("x", "center")) - resolved_y = y or str(preset.pop("y", "80%")) + definition = resolve_text_template(template) if template else {} + preset = dict(definition.get("style", {})) + resolved_x = x or str(definition.get("x", "center")) + resolved_y = y or str(definition.get("y", "80%")) + template_parameters = dict(definition.get("parameters", {})) + if accent_color is not None: + template_parameters["accent_color"] = accent_color style_values = { **preset, "font_family": font, @@ -383,6 +350,7 @@ def operation(candidate): return add_text_overlay( candidate, text=text, + subtitle=subtitle, at=at_seconds, duration=duration_seconds, x=resolved_x, @@ -391,6 +359,8 @@ def operation(candidate): style=style, entrance=entrance, exit=exit_animation, + template=template, + template_parameters=template_parameters, ) result, state = manager.mutate( @@ -399,12 +369,14 @@ def operation(candidate): operation, command={ "text": text, + "subtitle": subtitle, "at": at, "duration": duration, "x": resolved_x, "y": resolved_y, "track": track, "template": template, + "accent_color": accent_color, }, dry_run=dry_run, ) @@ -421,8 +393,8 @@ def text_presets(ctx: typer.Context) -> None: emit( _state(ctx), - success_response("text.presets", TEXT_TEMPLATES), - human=json.dumps(TEXT_TEMPLATES, ensure_ascii=False, indent=2), + success_response("text.presets", list_text_templates()), + human=json.dumps(list_text_templates(), ensure_ascii=False, indent=2), ) @@ -448,7 +420,7 @@ def text_import_csv( template_name = row.get("template") or default_template if template_name not in TEXT_TEMPLATES: raise ValueError(f'Unknown text template "{template_name}".') - preset = dict(TEXT_TEMPLATES[template_name]) + definition = resolve_text_template(template_name) prepared.append( { "text": row["text"], @@ -456,10 +428,11 @@ def text_import_csv( "duration": float( parse_time(row["duration"], document.project.fps).seconds ), - "x": preset.pop("x", "center"), - "y": preset.pop("y", "80%"), - "style": TextStyle.model_validate(preset), + "x": definition.get("x", "center"), + "y": definition.get("y", "80%"), + "style": TextStyle.model_validate(definition.get("style", {})), "template": template_name, + "template_parameters": definition.get("parameters", {}), } ) @@ -473,6 +446,8 @@ def operation(candidate): x=item["x"], y=item["y"], style=item["style"], + template=item["template"], + template_parameters=item["template_parameters"], ) for item in prepared ] diff --git a/src/facut/core/models.py b/src/facut/core/models.py index d40a906..6e8c96a 100644 --- a/src/facut/core/models.py +++ b/src/facut/core/models.py @@ -109,6 +109,15 @@ class MediaTechnicalInfo(StrictModel): has_subtitles: bool = False variable_frame_rate: bool = False creation_time: str | None = None + timecode: str | None = None + timezone_offset: str | None = None + camera_make: str | None = None + camera_model: str | None = None + lens_model: str | None = None + latitude: float | None = Field(default=None, ge=-90.0, le=90.0) + longitude: float | None = Field(default=None, ge=-180.0, le=180.0) + altitude: float | None = None + dynamic_range: Literal["sdr", "hdr-pq", "hdr-hlg", "log", "unknown"] = "unknown" keyframes: list[float] = Field(default_factory=list) @@ -335,6 +344,7 @@ class TextOverlay(StrictModel): id: str = Field(default_factory=lambda: new_id("text")) track_id: str | None = None text: str = Field(min_length=1) + subtitle: str | None = None at: float = Field(ge=0.0) duration: float = Field(gt=0.0) x: float | str = "center" @@ -342,6 +352,8 @@ class TextOverlay(StrictModel): style: TextStyle = Field(default_factory=TextStyle) entrance: str | None = None exit: str | None = None + template: str | None = None + template_parameters: dict[str, Any] = Field(default_factory=dict) enabled: bool = True metadata: dict[str, Any] = Field(default_factory=dict) diff --git a/src/facut/media/probe.py b/src/facut/media/probe.py index 668b249..ce81a1f 100644 --- a/src/facut/media/probe.py +++ b/src/facut/media/probe.py @@ -3,6 +3,7 @@ from __future__ import annotations import json +import re from fractions import Fraction from pathlib import Path from typing import Any @@ -120,6 +121,9 @@ def _parse_probe(payload: dict[str, Any]) -> MediaTechnicalInfo: audio = next((stream for stream in streams if stream.get("codec_type") == "audio"), {}) tags = container.get("tags") or {} video_tags = video.get("tags") or {} + normalized_tags = { + str(key).casefold(): value for key, value in {**tags, **video_tags}.items() + } side_data = video.get("side_data_list") or [] rotation = video_tags.get("rotate") if rotation is None: @@ -140,6 +144,12 @@ def _parse_probe(payload: dict[str, Any]) -> MediaTechnicalInfo: (_number(stream.get("duration")) or 0.0 for stream in streams), default=0.0, ) + creation_time = _first_tag( + normalized_tags, "creation_time", "com.apple.quicktime.creationdate", "date" + ) + latitude, longitude, altitude = _location(normalized_tags) + color_transfer = video.get("color_transfer") + dynamic_range = _dynamic_range(color_transfer, normalized_tags) return MediaTechnicalInfo( container=container.get("format_name"), duration=duration, @@ -152,15 +162,97 @@ def _parse_probe(payload: dict[str, Any]) -> MediaTechnicalInfo: average_frame_rate=average_rate, pixel_format=video.get("pix_fmt"), color_space=video.get("color_space"), - color_transfer=video.get("color_transfer"), + color_transfer=color_transfer, color_primaries=video.get("color_primaries"), audio_channels=_integer(audio.get("channels")), sample_rate=_integer(audio.get("sample_rate")), rotation=int(rotation or 0), has_subtitles=any(stream.get("codec_type") == "subtitle" for stream in streams), variable_frame_rate=variable, - creation_time=tags.get("creation_time") or video_tags.get("creation_time"), + creation_time=creation_time, + timecode=_first_tag(normalized_tags, "timecode", "com.apple.quicktime.timecode"), + timezone_offset=_timezone_offset(creation_time) + or _first_tag(normalized_tags, "time_zone", "timezone"), + camera_make=_first_tag( + normalized_tags, "make", "com.apple.quicktime.make", "manufacturer" + ), + camera_model=_first_tag( + normalized_tags, "model", "com.apple.quicktime.model", "camera_model" + ), + lens_model=_first_tag( + normalized_tags, "lens_model", "lensmodel", "com.apple.quicktime.lens.model" + ), + latitude=latitude, + longitude=longitude, + altitude=altitude, + dynamic_range=dynamic_range, + ) + + +def _first_tag(tags: dict[str, Any], *names: str) -> str | None: + for name in names: + value = tags.get(name.casefold()) + if value not in {None, ""}: + return str(value) + return None + + +_ISO6709 = re.compile( + r"^(?P[+-]\d+(?:\.\d+)?)(?P[+-]\d+(?:\.\d+)?)" + r"(?P[+-]\d+(?:\.\d+)?)?/?$" +) + + +def _location(tags: dict[str, Any]) -> tuple[float | None, float | None, float | None]: + location = _first_tag( + tags, + "com.apple.quicktime.location.iso6709", + "location", + "location-eng", + ) + if location: + match = _ISO6709.match(location.strip()) + if match: + return ( + _number(match.group("lat")), + _number(match.group("lon")), + _number(match.group("alt")), + ) + return ( + _number(_first_tag(tags, "gps_latitude", "latitude")), + _number(_first_tag(tags, "gps_longitude", "longitude")), + _number(_first_tag(tags, "gps_altitude", "altitude")), + ) + + +def _timezone_offset(value: str | None) -> str | None: + if not value: + return None + match = re.search(r"([+-]\d{2}:?\d{2}|Z)$", value.strip(), re.I) + if not match: + return None + offset = match.group(1).upper() + if offset == "Z": + return "+00:00" + return offset if ":" in offset else f"{offset[:3]}:{offset[3:]}" + + +def _dynamic_range(transfer: Any, tags: dict[str, Any]) -> str: + normalized = str(transfer or "").casefold() + if normalized in {"smpte2084", "pq"}: + return "hdr-pq" + if normalized in {"arib-std-b67", "hlg"}: + return "hdr-hlg" + descriptive = " ".join( + str(value).casefold() + for key, value in tags.items() + if any(token in key for token in ("gamma", "profile", "color")) ) + if "log" in descriptive or normalized.startswith("log"): + return "log" + if normalized in {"bt709", "iec61966-2-1", "smpte170m", "bt470bg"}: + return "sdr" + return "unknown" def _ratio(value: Any) -> float | None: diff --git a/src/facut/render/ffmpeg_backend.py b/src/facut/render/ffmpeg_backend.py index f0abc7c..3aa9211 100644 --- a/src/facut/render/ffmpeg_backend.py +++ b/src/facut/render/ffmpeg_backend.py @@ -120,6 +120,8 @@ def render( audio_bitrate: str = "192k", bitrate: str | None = None, hardware: str = "auto", + color_space: str | None = None, + audio_sample_rate: int | None = None, overwrite: bool = False, preview: bool = False, range_from: float | None = None, @@ -162,6 +164,8 @@ def render( audio_codec=audio_codec, audio_bitrate=audio_bitrate, bitrate=bitrate, + color_space=color_space, + audio_sample_rate=audio_sample_rate, preview=preview, overwrite=overwrite, progress=progress, @@ -183,6 +187,8 @@ def render( audio_codec=audio_codec, audio_bitrate=audio_bitrate, bitrate=bitrate, + color_space=color_space, + audio_sample_rate=audio_sample_rate, preview=preview, overwrite=True, progress=progress, @@ -256,6 +262,8 @@ def _run( audio_codec: str, audio_bitrate: str, bitrate: str | None, + color_space: str | None, + audio_sample_rate: int | None, preview: bool, overwrite: bool, progress: ProgressCallback | None, @@ -289,12 +297,30 @@ def _run( args.extend(["-b:v", bitrate or ("4M" if preview else "12M")]) if bitrate and choice.encoder != "h264_videotoolbox": args.extend(["-maxrate", bitrate, "-bufsize", bitrate]) + if color_space: + args.extend( + [ + "-pix_fmt", "yuv420p", + "-color_primaries", color_space, + "-color_trc", color_space, + "-colorspace", color_space, + ] + ) + if color_space == "bt709": + args.extend( + [ + "-bsf:v", + "h264_metadata=colour_primaries=1:" + "transfer_characteristics=1:matrix_coefficients=1", + ] + ) args.extend( [ "-c:a", audio_codec, "-b:a", audio_bitrate, + *(["-ar", str(audio_sample_rate)] if audio_sample_rate else []), "-t", f"{graph.duration:.9f}", "-shortest", diff --git a/src/facut/render/incremental.py b/src/facut/render/incremental.py index 9de7c16..05ead8d 100644 --- a/src/facut/render/incremental.py +++ b/src/facut/render/incremental.py @@ -130,6 +130,8 @@ def render( audio_bitrate: str = "320k", bitrate: str | None = None, hardware: str = "auto", + color_space: str | None = None, + audio_sample_rate: int | None = None, overwrite: bool = False, progress: ProgressCallback | None = None, ) -> IncrementalRenderResult: @@ -177,6 +179,8 @@ def render( "audio_bitrate": audio_bitrate, "bitrate": bitrate, "hardware": hardware, + "color_space": color_space, + "audio_sample_rate": audio_sample_rate, } key = cache_key( inputs=[source], @@ -239,6 +243,8 @@ def segment_progress(event: dict[str, Any]) -> None: audio_bitrate=audio_bitrate, bitrate=bitrate, hardware=hardware, + color_space=color_space, + audio_sample_rate=audio_sample_rate, overwrite=False, progress=segment_progress, ) @@ -277,6 +283,25 @@ def segment_progress(event: dict[str, Any]) -> None: audio_codec, "-b:a", audio_bitrate, + *(["-ar", str(audio_sample_rate)] if audio_sample_rate else []), + *( + [ + "-color_primaries", color_space, + "-color_trc", color_space, + "-colorspace", color_space, + ] + if color_space + else [] + ), + *( + [ + "-bsf:v", + "h264_metadata=colour_primaries=1:" + "transfer_characteristics=1:matrix_coefficients=1", + ] + if color_space == "bt709" + else [] + ), "-t", f"{project.project.duration:.9f}", "-movflags", diff --git a/src/facut/render/presets.py b/src/facut/render/presets.py new file mode 100644 index 0000000..73df9a7 --- /dev/null +++ b/src/facut/render/presets.py @@ -0,0 +1,135 @@ +"""Validated delivery presets and source-frame-rate resolution.""" + +from __future__ import annotations + +from copy import deepcopy +from typing import Any + + +RENDER_PRESETS: dict[str, dict[str, Any]] = { + "youtube-1080p": { + "platform": "youtube", + "width": 1920, + "height": 1080, + "fps": None, + "bitrate": "8M", + "high_fps_bitrate": "12M", + "audio_bitrate": "384k", + "audio_sample_rate": 48000, + "color_space": "bt709", + "fast_start": True, + "source": "YouTube recommended upload encoding settings", + }, + "youtube-4k": { + "platform": "youtube", + "width": 3840, + "height": 2160, + "fps": None, + "bitrate": "45M", + "high_fps_bitrate": "68M", + "audio_bitrate": "384k", + "audio_sample_rate": 48000, + "color_space": "bt709", + "fast_start": True, + "source": "YouTube recommended upload encoding settings", + }, + "youtube-4k-sdr": { + "inherits": "youtube-4k", + "description": "4K SDR, source frame rate, BT.709, AAC 48 kHz, Fast Start.", + }, + "bilibili-1080p": { + "platform": "bilibili", + "width": 1920, + "height": 1080, + "fps": None, + "bitrate": "12M", + "high_fps_bitrate": "18M", + "audio_bitrate": "320k", + "audio_sample_rate": 48000, + "color_space": "bt709", + "fast_start": True, + "source": "FACUT creator workflow default; not represented as an official maximum.", + }, + "bilibili-4k": { + "platform": "bilibili", + "width": 3840, + "height": 2160, + "fps": None, + "bitrate": "45M", + "high_fps_bitrate": "60M", + "audio_bitrate": "320k", + "audio_sample_rate": 48000, + "color_space": "bt709", + "fast_start": True, + "source": "FACUT creator workflow default; not represented as an official maximum.", + }, + "shorts-9x16": { + "platform": "youtube-shorts", + "width": 2160, + "height": 3840, + "fps": None, + "bitrate": "45M", + "high_fps_bitrate": "68M", + "audio_bitrate": "384k", + "audio_sample_rate": 48000, + "color_space": "bt709", + "fast_start": True, + "source": "YouTube codec guidance with a vertical canvas.", + }, + "tiktok-1080x1920": { + "platform": "tiktok", + "width": 1080, + "height": 1920, + "fps": None, + "bitrate": "12M", + "high_fps_bitrate": "18M", + "audio_bitrate": "320k", + "audio_sample_rate": 48000, + "color_space": "bt709", + "fast_start": True, + "source": "FACUT workflow default.", + }, + "community-1x1": { + "platform": "community", + "width": 2160, + "height": 2160, + "fps": None, + "bitrate": "24M", + "high_fps_bitrate": "36M", + "audio_bitrate": "320k", + "audio_sample_rate": 48000, + "color_space": "bt709", + "fast_start": True, + "source": "FACUT workflow default.", + }, +} + + +def _definition(name: str) -> dict[str, Any]: + if name not in RENDER_PRESETS: + raise KeyError(name) + item = deepcopy(RENDER_PRESETS[name]) + parent = item.pop("inherits", None) + if parent: + base = _definition(parent) + base.update(item) + return base + return item + + +def resolve_render_preset( + name: str, *, source_fps: float, requested_fps: float | None = None +) -> dict[str, Any]: + """Resolve inheritance, retain source fps, and select the matching bitrate tier.""" + + item = _definition(name) + fps = requested_fps or item.get("fps") or source_fps + item["fps"] = float(fps) + if float(fps) >= 48 and item.get("high_fps_bitrate"): + item["bitrate"] = item["high_fps_bitrate"] + item["name"] = name + return item + + +def list_render_presets() -> dict[str, dict[str, Any]]: + return {name: _definition(name) for name in RENDER_PRESETS} diff --git a/src/facut/schemas/project.schema.json b/src/facut/schemas/project.schema.json index e10336f..d0e0db9 100644 --- a/src/facut/schemas/project.schema.json +++ b/src/facut/schemas/project.schema.json @@ -782,6 +782,118 @@ "default": null, "title": "Creation Time" }, + "timecode": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Timecode" + }, + "timezone_offset": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Timezone Offset" + }, + "camera_make": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Camera Make" + }, + "camera_model": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Camera Model" + }, + "lens_model": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Lens Model" + }, + "latitude": { + "anyOf": [ + { + "maximum": 90.0, + "minimum": -90.0, + "type": "number" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Latitude" + }, + "longitude": { + "anyOf": [ + { + "maximum": 180.0, + "minimum": -180.0, + "type": "number" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Longitude" + }, + "altitude": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Altitude" + }, + "dynamic_range": { + "default": "unknown", + "enum": [ + "sdr", + "hdr-pq", + "hdr-hlg", + "log", + "unknown" + ], + "title": "Dynamic Range", + "type": "string" + }, "keyframes": { "items": { "type": "number" @@ -958,6 +1070,18 @@ "title": "Text", "type": "string" }, + "subtitle": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Subtitle" + }, "at": { "minimum": 0.0, "title": "At", @@ -1019,6 +1143,23 @@ "default": null, "title": "Exit" }, + "template": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Template" + }, + "template_parameters": { + "additionalProperties": true, + "title": "Template Parameters", + "type": "object" + }, "enabled": { "default": true, "title": "Enabled", diff --git a/src/facut/subtitles/compiler.py b/src/facut/subtitles/compiler.py index b93c28a..88ac113 100644 --- a/src/facut/subtitles/compiler.py +++ b/src/facut/subtitles/compiler.py @@ -5,7 +5,8 @@ from dataclasses import dataclass from pathlib import Path -from facut.core.models import ProjectDocument, TextStyle +from facut.core.models import ProjectDocument, TextOverlay, TextStyle +from facut.subtitles.templates import resolve_text_template @dataclass(frozen=True, slots=True) @@ -44,6 +45,14 @@ def compile(self, document: ProjectDocument) -> SubtitleRenderPlan: (item for item in document.text_overlays if item.enabled), key=lambda item: (item.at, item.id), ): + if overlay.template: + definition = resolve_text_template(overlay.template) + renderer = definition.get("renderer", "standard") + if renderer.startswith("lingang-"): + events.extend( + self._lingang_events(document, overlay, definition, styles) + ) + continue style_name = self._style_name(styles, overlay.style) x = self._position(overlay.x, document.project.width, axis="x") y = self._position(overlay.y, document.project.height, axis="y") @@ -145,12 +154,144 @@ def _dialogue( text: str, *, effect: str = "", + layer: int = 0, ) -> str: return ( - f"Dialogue: 0,{self._ass_time(start)},{self._ass_time(end)}," + f"Dialogue: {layer},{self._ass_time(start)},{self._ass_time(end)}," f"{style_name},,0,0,0,{effect},{text}" ) + def _lingang_events( + self, + document: ProjectDocument, + overlay: TextOverlay, + definition: dict[str, object], + styles: list[TextStyle], + ) -> list[str]: + """Render the Lingang editorial system as ASS vector and text layers.""" + + width = document.project.width + height = document.project.height + scale = height / 1080.0 + parameters = dict(definition.get("parameters", {})) + parameters.update(overlay.template_parameters) + x = self._position(overlay.x, width, axis="x") + y = self._position(overlay.y, height, axis="y") + panel_width = width * float(parameters.get("panel_width_percent", 37.5)) / 100 + panel_height = height * float(parameters.get("panel_height_percent", 14.8)) / 100 + radius = float(parameters.get("corner_radius", 22.0)) * scale + + outline = self._shape_event( + overlay, + self._rounded_rectangle(x, y, panel_width, panel_height, radius), + str(parameters.get("panel_outline", "#FFFFFF18")), + layer=0, + ) + inset = max(1.0, scale) + panel = self._shape_event( + overlay, + self._rounded_rectangle( + x + inset, + y + inset, + panel_width - 2 * inset, + panel_height - 2 * inset, + max(1.0, radius - inset), + ), + str(parameters.get("panel_color", "#030A12A4")), + layer=1, + ) + accent_width = max(5.0 * scale, panel_width * 0.009) + accent_margin = 22.0 * scale + accent = self._shape_event( + overlay, + self._rounded_rectangle( + x + 20.0 * scale, + y + accent_margin, + accent_width, + panel_height - 2 * accent_margin, + accent_width / 2, + ), + str(parameters.get("accent_color", "#66E1FF")), + layer=2, + ) + + text_x = x + 52.0 * scale + main_title = definition.get("renderer") == "lingang-main-title" + title_y = y + (58.0 if main_title else 36.0) * scale + title_style = overlay.style.model_copy( + update={"font_size": overlay.style.font_size * scale, "background": None} + ) + title_name = self._style_name(styles, title_style) + title = self._dialogue( + overlay.at, + overlay.end, + title_name, + f"{{\\an7\\pos({text_x:.2f},{title_y:.2f})}}{self._escape(overlay.text)}", + effect=overlay.entrance or "", + layer=3, + ) + events = [outline, panel, accent, title] + if overlay.subtitle: + subtitle_size = float(parameters.get("subtitle_font_size", 25.0)) * scale + subtitle_style = overlay.style.model_copy( + update={ + "font_size": subtitle_size, + "font_weight": "normal", + "color": str(parameters.get("subtitle_color", "#BEDEE8")), + "background": None, + } + ) + subtitle_name = self._style_name(styles, subtitle_style) + subtitle_y = y + (158.0 if main_title else 94.0) * scale + events.append( + self._dialogue( + overlay.at, + overlay.end, + subtitle_name, + f"{{\\an7\\pos({text_x:.2f},{subtitle_y:.2f})}}" + f"{self._escape(overlay.subtitle)}", + layer=4, + ) + ) + return events + + def _shape_event( + self, overlay: TextOverlay, drawing: str, color: str, *, layer: int + ) -> str: + bgr, alpha = self._inline_ass_color(color) + text = ( + f"{{\\an7\\pos(0,0)\\bord0\\shad0\\p1" + f"\\1c&H{bgr}&\\1a&H{alpha}&}}{drawing}{{\\p0}}" + ) + return self._dialogue( + overlay.at, overlay.end, "Style0", text, layer=layer + ) + + @staticmethod + def _inline_ass_color(value: str) -> tuple[str, str]: + raw = value.lstrip("#") + red, green, blue = raw[0:2], raw[2:4], raw[4:6] + opacity = int(raw[6:8], 16) if len(raw) == 8 else 255 + return f"{blue}{green}{red}", f"{255 - opacity:02X}" + + @staticmethod + def _rounded_rectangle(x: float, y: float, width: float, height: float, radius: float) -> str: + x0, y0 = x, y + x1, y1 = x + width, y + height + radius = min(radius, width / 2, height / 2) + k = radius * 0.55228475 + return ( + f"m {x0 + radius:.0f} {y0:.0f} " + f"l {x1 - radius:.0f} {y0:.0f} " + f"b {x1 - radius + k:.0f} {y0:.0f} {x1:.0f} {y0 + radius - k:.0f} {x1:.0f} {y0 + radius:.0f} " + f"l {x1:.0f} {y1 - radius:.0f} " + f"b {x1:.0f} {y1 - radius + k:.0f} {x1 - radius + k:.0f} {y1:.0f} {x1 - radius:.0f} {y1:.0f} " + f"l {x0 + radius:.0f} {y1:.0f} " + f"b {x0 + radius - k:.0f} {y1:.0f} {x0:.0f} {y1 - radius + k:.0f} {x0:.0f} {y1 - radius:.0f} " + f"l {x0:.0f} {y0 + radius:.0f} " + f"b {x0:.0f} {y0 + radius - k:.0f} {x0 + radius - k:.0f} {y0:.0f} {x0 + radius:.0f} {y0:.0f}" + ) + @staticmethod def _escape(text: str) -> str: return ( diff --git a/src/facut/subtitles/editor.py b/src/facut/subtitles/editor.py index 8693983..068ad0d 100644 --- a/src/facut/subtitles/editor.py +++ b/src/facut/subtitles/editor.py @@ -94,6 +94,7 @@ def add_text_overlay( document: ProjectDocument, *, text: str, + subtitle: str | None = None, at: float, duration: float, x: float | str = "center", @@ -102,11 +103,14 @@ def add_text_overlay( style: TextStyle | None = None, entrance: str | None = None, exit: str | None = None, + template: str | None = None, + template_parameters: dict[str, object] | None = None, ) -> TextOverlay: if track_id is not None and document.find_track(track_id) is None: raise SubtitleEditError(f'Track "{track_id}" was not found.') overlay = TextOverlay( text=text, + subtitle=subtitle, at=at, duration=duration, x=x, @@ -115,6 +119,8 @@ def add_text_overlay( style=style or TextStyle(), entrance=entrance, exit=exit, + template=template, + template_parameters=template_parameters or {}, ) document.text_overlays.append(overlay) document.text_overlays.sort(key=lambda item: (item.at, item.id)) diff --git a/src/facut/subtitles/templates.py b/src/facut/subtitles/templates.py new file mode 100644 index 0000000..b6248e9 --- /dev/null +++ b/src/facut/subtitles/templates.py @@ -0,0 +1,164 @@ +"""Built-in title templates with stable, machine-readable parameters.""" + +from __future__ import annotations + +from copy import deepcopy +from typing import Any + + +TEXT_TEMPLATES: dict[str, dict[str, Any]] = { + "documentary-lower-third": { + "description": "Neutral documentary lower third.", + "renderer": "standard", + "x": "8%", + "y": "82%", + "style": { + "font_size": 52.0, + "color": "#FFFFFF", + "stroke_color": "#000000", + "stroke_width": 1.5, + "background": "#00000099", + "shadow": 2.0, + "alignment": "left", + "safe_area": True, + }, + }, + "chapter": { + "description": "Centered chapter card.", + "renderer": "standard", + "x": "center", + "y": "center", + "style": { + "font_size": 84.0, + "color": "#FFFFFF", + "stroke_width": 2.0, + "shadow": 3.0, + "alignment": "center", + "safe_area": True, + }, + }, + "song-title": { + "description": "Compact music credit card.", + "renderer": "standard", + "x": "8%", + "y": "12%", + "style": { + "font_size": 46.0, + "color": "#FFFFFF", + "stroke_width": 1.0, + "background": "#101820B3", + "shadow": 2.0, + "alignment": "left", + "safe_area": True, + }, + }, + "caption-box": { + "description": "Centered accessible caption box.", + "renderer": "standard", + "x": "center", + "y": "88%", + "style": { + "font_size": 48.0, + "color": "#FFFFFF", + "stroke_width": 0.0, + "background": "#000000B3", + "shadow": 0.0, + "alignment": "center", + "safe_area": True, + }, + }, + "lingang-cinematic-panel": { + "description": "Lingang cinematic bilingual panel with cyan accent.", + "renderer": "lingang-panel", + "x": "5%", + "y": "71.3%", + "style": { + "font_size": 46.0, + "font_weight": "bold", + "color": "#FFFFFF", + "stroke_width": 0.0, + "shadow": 0.0, + "alignment": "left", + "safe_area": True, + }, + "parameters": { + "panel_color": "#030A12A4", + "panel_outline": "#FFFFFF18", + "accent_color": "#66E1FF", + "subtitle_color": "#BEDEE8", + "subtitle_font_size": 25.0, + "panel_width_percent": 37.5, + "panel_height_percent": 14.8, + "corner_radius": 22.0, + }, + }, + "lingang-cinematic-mint": { + "description": "Lingang panel with a hopeful mint accent.", + "inherits": "lingang-cinematic-panel", + "parameters": {"accent_color": "#74EFCB"}, + }, + "lingang-cinematic-warm": { + "description": "Lingang panel with a warm human-story accent.", + "inherits": "lingang-cinematic-panel", + "parameters": {"accent_color": "#FFC468"}, + }, + "lingang-day-card": { + "description": "Lingang day/chapter card for a section change.", + "inherits": "lingang-cinematic-panel", + "style": {"font_size": 52.0}, + "parameters": { + "accent_color": "#66E1FF", + "panel_width_percent": 42.0, + }, + }, + "lingang-main-title": { + "description": "Large Lingang opening title with cyan editorial accent.", + "renderer": "lingang-main-title", + "x": "8%", + "y": "30%", + "style": { + "font_size": 82.0, + "font_weight": "bold", + "color": "#FFFFFF", + "stroke_width": 0.0, + "shadow": 0.0, + "alignment": "left", + "safe_area": True, + }, + "parameters": { + "panel_color": "#020A12A6", + "panel_outline": "#FFFFFF18", + "accent_color": "#61E1FF", + "subtitle_color": "#D8F2F9", + "subtitle_font_size": 49.0, + "panel_width_percent": 48.0, + "panel_height_percent": 28.0, + "corner_radius": 26.0, + }, + }, +} + + +def resolve_text_template(name: str) -> dict[str, Any]: + """Resolve inheritance and return an isolated template dictionary.""" + + if name not in TEXT_TEMPLATES: + raise KeyError(name) + raw = deepcopy(TEXT_TEMPLATES[name]) + parent_name = raw.pop("inherits", None) + if parent_name is None: + return raw + parent = resolve_text_template(parent_name) + for key, value in raw.items(): + if isinstance(value, dict) and isinstance(parent.get(key), dict): + parent[key].update(value) + else: + parent[key] = value + parent["name"] = name + return parent + + +def list_text_templates() -> dict[str, dict[str, Any]]: + """Return fully resolved definitions for CLI and Agent discovery.""" + + return {name: resolve_text_template(name) for name in TEXT_TEMPLATES} diff --git a/tests/test_ingest_cli.py b/tests/test_ingest_cli.py new file mode 100644 index 0000000..0a58829 --- /dev/null +++ b/tests/test_ingest_cli.py @@ -0,0 +1,31 @@ +from __future__ import annotations + +import json + +from typer.testing import CliRunner + +from facut.cli.main import app + + +def test_ingest_creates_4k_trip_project_and_verifies_hashes(tmp_path) -> None: + source = tmp_path / "JapanTrip" + source.mkdir() + (source / "notes.srt").write_text( + "1\n00:00:00,000 --> 00:00:01,000\nTokyo\n", encoding="utf-8" + ) + output = tmp_path / "project" + result = CliRunner().invoke( + app, + [ + "--json", "ingest", str(source), "--trip", "日本旅行2026", + "--output", str(output), "--verify", "sha256", "--proxy", "none", + ], + ) + assert result.exit_code == 0, result.output + payload = json.loads(result.stdout) + assert payload["data"]["verification"]["asset_count"] == 1 + project = json.loads((output / "facut.json").read_text(encoding="utf-8")) + assert project["project"]["width"] == 3840 + assert project["project"]["height"] == 2160 + assert project["settings"]["trip"]["name"] == "日本旅行2026" + assert len(project["media"][0]["sha256"]) == 64 diff --git a/tests/test_media_probe.py b/tests/test_media_probe.py index 0aa467d..3bef138 100644 --- a/tests/test_media_probe.py +++ b/tests/test_media_probe.py @@ -6,7 +6,7 @@ import pytest -from facut.media.probe import probe_media +from facut.media.probe import _parse_probe, probe_media @pytest.fixture() @@ -61,3 +61,40 @@ def test_probe_extracts_video_and_audio_metadata(sample_video) -> None: def test_probe_missing_file() -> None: with pytest.raises(FileNotFoundError): probe_media("definitely-does-not-exist.mp4") + + +def test_probe_parses_camera_gps_timezone_and_hdr_metadata() -> None: + info = _parse_probe( + { + "format": { + "format_name": "mov,mp4", + "duration": "2.0", + "tags": { + "creation_time": "2026-07-20T18:30:00+08:00", + "com.apple.quicktime.make": "Apple", + "com.apple.quicktime.model": "iPhone 17 Pro", + "com.apple.quicktime.location.ISO6709": "+31.2304+121.4737+004.2/", + }, + }, + "streams": [ + { + "codec_type": "video", + "codec_name": "hevc", + "width": 3840, + "height": 2160, + "r_frame_rate": "30/1", + "avg_frame_rate": "30/1", + "color_transfer": "smpte2084", + "tags": {"timecode": "10:00:00:00"}, + } + ], + } + ) + assert info.camera_make == "Apple" + assert info.camera_model == "iPhone 17 Pro" + assert info.latitude == pytest.approx(31.2304) + assert info.longitude == pytest.approx(121.4737) + assert info.altitude == pytest.approx(4.2) + assert info.timezone_offset == "+08:00" + assert info.dynamic_range == "hdr-pq" + assert info.timecode == "10:00:00:00" diff --git a/tests/test_render_presets.py b/tests/test_render_presets.py new file mode 100644 index 0000000..cc8e87d --- /dev/null +++ b/tests/test_render_presets.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from facut.render.presets import list_render_presets, resolve_render_preset + + +def test_youtube_4k_retains_source_fps_and_selects_bitrate_tier() -> None: + standard = resolve_render_preset("youtube-4k-sdr", source_fps=25) + high = resolve_render_preset("youtube-4k-sdr", source_fps=60) + assert standard["fps"] == 25 + assert standard["bitrate"] == "45M" + assert high["fps"] == 60 + assert high["bitrate"] == "68M" + assert high["audio_bitrate"] == "384k" + assert high["audio_sample_rate"] == 48000 + assert high["color_space"] == "bt709" + assert high["fast_start"] is True + + +def test_multi_platform_presets_are_machine_discoverable() -> None: + presets = list_render_presets() + assert {"youtube-4k-sdr", "bilibili-4k", "shorts-9x16", "community-1x1"} <= set(presets) + assert presets["shorts-9x16"]["width"] < presets["shorts-9x16"]["height"] diff --git a/tests/test_subtitle_cli.py b/tests/test_subtitle_cli.py index 99a35bf..31d313a 100644 --- a/tests/test_subtitle_cli.py +++ b/tests/test_subtitle_cli.py @@ -152,3 +152,28 @@ def test_import_shift_export_text_and_compile(tmp_path) -> None: assert compiled["data"]["cue_count"] == 2 assert compiled["data"]["text_overlay_count"] == 1 assert "[Events]" in ass.read_text(encoding="utf-8-sig") + + +def test_lingang_template_is_discoverable_and_persisted(tmp_path) -> None: + project = tmp_path / "travel" + _json(runner.invoke(app, ["--json", "init", str(project), "--width", "3840", "--height", "2160"])) + presets = _json(runner.invoke(app, ["--json", "text", "presets"])) + template = presets["data"]["lingang-cinematic-panel"] + assert template["renderer"] == "lingang-panel" + assert template["parameters"]["accent_color"] == "#66E1FF" + + result = _json( + runner.invoke( + app, + [ + "--project", str(project), "--json", "text", "add", + "--text", "再来", "--subtitle", "同一条雪道,重新滑下", + "--at", "0", "--duration", "2s", + "--template", "lingang-cinematic-mint", + ], + ) + ) + overlay = result["data"]["result"] + assert overlay["template"] == "lingang-cinematic-mint" + assert overlay["subtitle"] == "同一条雪道,重新滑下" + assert overlay["template_parameters"]["accent_color"] == "#74EFCB" diff --git a/tests/test_subtitle_editor.py b/tests/test_subtitle_editor.py index 0f06dde..090898e 100644 --- a/tests/test_subtitle_editor.py +++ b/tests/test_subtitle_editor.py @@ -74,3 +74,26 @@ def test_ass_compiler_includes_cues_and_positioned_text() -> None: assert r"\pos(960.00,216.00)" in plan.content assert "临港 VLOG" in plan.content + +def test_lingang_template_compiles_vector_panel_and_bilingual_layers() -> None: + project = _project() + project.project.width = 3840 + project.project.height = 2160 + add_text_overlay( + project, + text="抬头,是更大的尺度", + subtitle="LOOK UP · THE SCALE CHANGES", + at=0, + duration=3, + x="5%", + y="71.3%", + template="lingang-cinematic-panel", + template_parameters={"accent_color": "#66E1FF"}, + ) + plan = SubtitleCompiler().compile(project) + assert r"\p1" in plan.content + assert "Dialogue: 4" in plan.content + assert "抬头,是更大的尺度" in plan.content + assert "LOOK UP · THE SCALE CHANGES" in plan.content + assert "FFE166" in plan.content # ASS BGR form of #66E1FF. + assert "Fontsize" in plan.content diff --git a/tests/test_travel_analysis.py b/tests/test_travel_analysis.py new file mode 100644 index 0000000..f2acf2f --- /dev/null +++ b/tests/test_travel_analysis.py @@ -0,0 +1,36 @@ +from __future__ import annotations + +from facut.analysis.travel import analyze_travel_metadata +from facut.core.models import MediaTechnicalInfo + + +def test_travel_analysis_reports_evidence_and_uncertainty(tmp_path) -> None: + source = tmp_path / "日本旅行" / "酒店" / "DJI_Mavic_日落.mp4" + source.parent.mkdir(parents=True) + source.write_bytes(b"placeholder") + technical = MediaTechnicalInfo( + creation_time="2026-07-20T18:30:00+09:00", + timezone_offset="+09:00", + camera_make="DJI", + camera_model="Mavic 4 Pro", + color_transfer="bt709", + dynamic_range="sdr", + ) + result = analyze_travel_metadata(source, technical) + labels = {item["label"] for item in result["candidates"]} + assert {"hotel", "aerial", "drone", "sunset-window", "sdr"} <= labels + assert all(item["evidence"] for item in result["candidates"]) + assert result["visual_semantics"]["status"] == "plugin_required" + + +def test_daypart_confidence_drops_without_timezone(tmp_path) -> None: + source = tmp_path / "clip.mp4" + source.write_bytes(b"x") + result = analyze_travel_metadata( + source, MediaTechnicalInfo(creation_time="2026-07-20T18:30:00") + ) + daypart = next( + item for item in result["candidates"] if item["dimension"] == "daypart" + ) + assert daypart["confidence"] < 0.6 + assert daypart["warning"] diff --git a/vendor/ffmpeg/README.md b/vendor/ffmpeg/README.md index bcae05c..e7f2a5b 100644 --- a/vendor/ffmpeg/README.md +++ b/vendor/ffmpeg/README.md @@ -21,3 +21,18 @@ You may instead pass explicit paths: The official `facut.exe` release asset includes the media tools and does not require a system FFmpeg installation. + +## v0.4 Windows release baseline + +FACUT 0.4 is built and hardware-tested with Gyan FFmpeg `8.0.1-essentials_build`. +FFmpeg 8.1.2 requires NVENC API 13.1 and failed on otherwise healthy NVIDIA +581.80 drivers that expose API 13.0, so the release intentionally stays on +8.0.1 until the driver compatibility floor is broadly available. + +```text +ffmpeg.exe SHA-256 5af82a0d4fe2b9eae211b967332ea97edfc51c6b328ca35b827e73eac560dc0d +ffprobe.exe SHA-256 192a1d6899059765ac8c39764fc3148d4e6049955956dc2029f81f4bd6a8972d +``` + +Both executables were checked with `facut doctor --sample-render`; NVENC and +QSV completed real sample encodes on the Windows release machine.