---
title: paths
---

<div class="python-reference">
<a id="fastvideo.eval.io.paths-functions"></a>
<a id="fastvideo.eval.io.paths"></a>
<p>Filesystem helpers shared by eval scripts.</p>
<p>Provides the prompt-sanitization, default filename convention, and
<code>(row, video_path) → eval-kwargs</code> builder. Free functions, not a
class — :class:<code>fastvideo.eval.Evaluator</code> is the only stateful object
in the eval surface; loops live in user scripts.</p>
<h2 id="fastvideo.eval.io.paths.sanitize_prompt"><code>fastvideo.eval.io.paths.sanitize_prompt</code></h2>
<pre class="doc-signature"><code>sanitize_prompt(prompt: str, max_len: int = 100) -&gt; str</code></pre>
<p>Prompt → safe filename stem.</p>
<details><summary>Source</summary><pre><code>def sanitize_prompt(prompt: str, max_len: int = 100) -&gt; str:
    &quot;&quot;&quot;Prompt → safe filename stem.&quot;&quot;&quot;
    s = _INVALID_CHARS.sub(&quot;&quot;, prompt&#91;:max_len&#93;).strip().strip(&quot;.&quot;)
    return re.sub(r&quot;\s+&quot;, &quot; &quot;, s) or &quot;output&quot;</code></pre></details>
<h2 id="fastvideo.eval.io.paths.default_filename"><code>fastvideo.eval.io.paths.default_filename</code></h2>
<pre class="doc-signature"><code>default_filename(row: dict, idx: int, ext: str = &#x27;.mp4&#x27;) -&gt; str</code></pre>
<p><code>&lt;sanitized-prompt&gt;-&lt;idx&gt;.mp4</code> — VBench-style.</p>
<details><summary>Source</summary><pre><code>def default_filename(row: dict, idx: int, ext: str = &quot;.mp4&quot;) -&gt; str:
    &quot;&quot;&quot;``&lt;sanitized-prompt&gt;-&lt;idx&gt;.mp4`` — VBench-style.&quot;&quot;&quot;
    return f&quot;&#123;sanitize_prompt(row&#91;&#x27;prompt&#x27;&#93;)&#125;-&#123;idx&#125;&#123;ext&#125;&quot;</code></pre></details>
<h2 id="fastvideo.eval.io.paths.glob_videos"><code>fastvideo.eval.io.paths.glob_videos</code></h2>
<pre class="doc-signature"><code>glob_videos(videos_dir: Path, row: dict, ext: str = &#x27;.mp4&#x27;) -&gt; list&#91;Path&#93;</code></pre>
<p>Find every generated video for <em>row</em>, sorted by trailing <code>-&lt;idx&gt;</code>.</p>
<details><summary>Source</summary><pre><code>def glob_videos(videos_dir: Path, row: dict, ext: str = &quot;.mp4&quot;) -&gt; list&#91;Path&#93;:
    &quot;&quot;&quot;Find every generated video for *row*, sorted by trailing ``-&lt;idx&gt;``.&quot;&quot;&quot;
    pattern = f&quot;&#123;sanitize_prompt(row&#91;&#x27;prompt&#x27;&#93;)&#125;-*&#123;ext&#125;&quot;
    files = list(videos_dir.glob(pattern))

    def _idx(p: Path) -&gt; int:
        try:
            return int(p.stem.rsplit(&quot;-&quot;, 1)&#91;1&#93;)
        except (IndexError, ValueError):
            return -1

    return sorted(files, key=_idx)</code></pre></details>
<h2 id="fastvideo.eval.io.paths.build_eval_kwargs"><code>fastvideo.eval.io.paths.build_eval_kwargs</code></h2>
<pre class="doc-signature"><code>build_eval_kwargs(row: dict, video_path: Path, *, fps: float = 24.0) -&gt; dict&#91;str, Any&#93;</code></pre>
<p>Build evaluator kwargs from a sample row + a video on disk.</p>
<p>Loads the video as <code>(T,C,H,W)</code> and adds the leading batch dim.
Forwards <code>prompt</code> (as scalar <code>text_prompt</code>) and
<code>auxiliary_info</code> (as scalar dict) when present on the row —
matches the one-sample-per-call contract that the evaluator and
every metric assume.</p>
<details><summary>Source</summary><pre><code>def build_eval_kwargs(row: dict, video_path: Path, *, fps: float = 24.0) -&gt; dict&#91;str, Any&#93;:
    &quot;&quot;&quot;Build evaluator kwargs from a sample row + a video on disk.

    Loads the video as ``(T,C,H,W)`` and adds the leading batch dim.
    Forwards ``prompt`` (as scalar ``text_prompt``) and
    ``auxiliary_info`` (as scalar dict) when present on the row —
    matches the one-sample-per-call contract that the evaluator and
    every metric assume.
    &quot;&quot;&quot;
    from fastvideo.eval.io.video import load_video

    video = load_video(str(video_path))  # (T, C, H, W) in &#91;0, 1&#93;
    kwargs: dict&#91;str, Any&#93; = &#123;
        &quot;video&quot;: video.unsqueeze(0),  # (1, T, C, H, W)
        &quot;fps&quot;: fps,
    &#125;
    if &quot;prompt&quot; in row:
        kwargs&#91;&quot;text_prompt&quot;&#93; = row&#91;&quot;prompt&quot;&#93;
    aux = row.get(&quot;auxiliary_info&quot;)
    if aux:
        kwargs&#91;&quot;auxiliary_info&quot;&#93; = aux
    return kwargs</code></pre></details>
</div>
