Skip to content

About

Local-first reproducible video editing skill for Codex using Python and FFmpeg

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Codex Video Editor

Codex Video Editor is a local-first Codex skill for turning user-supplied video and audio into a reproducible, music-led montage. Codex reviews deterministic footage indexes and contact sheets, proposes at least two narratives, builds an approved storyboard, materializes an FFmpeg timeline, and validates preview and master renders.

The project is intentionally narrow: creative decisions stay reviewable, media stays local, every input is hashed, and every editorial artifact, approval, and render is bound to an immutable revision.

Requirements and installation

  • Python 3.11 or 3.12.
  • FFmpeg and FFprobe with H.264 (libx264), AAC, and the filters checked by scripts/doctor.py.
  • Local source media. Optional speech analysis additionally requires a local faster-whisper model directory.

Install the Python package and recommended local-analysis dependencies from the skill directory:

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[analysis]'

On Windows PowerShell, activate the environment with:

py -3.12 -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -e ".[analysis]"

Install .[asr] only when local transcription is needed. These explicit installation commands may contact a package index; the skill itself never installs software or downloads models at runtime.

To make the skill discoverable, place or symlink this complete directory at either .agents/skills/codex-video-editor in a repository or ~/.agents/skills/codex-video-editor for your user account. Invoke it as $codex-video-editor. See OpenAI's skill documentation for discovery details.

Quick start

Start by asking Codex to use $codex-video-editor with the local source paths and creative idea. Codex will freeze the choices in a strict brief before editing. A minimal 30-second brief looks like this:

{
  "schema_version": "1.0",
  "idea": "A quiet arrival that builds into a joyful shared moment",
  "audience": "Friends and family",
  "tone": "Warm, intimate, energetic finish",
  "plot": ["Establish the place", "Reveal arrivals", "Build shared activity", "Resolve together"],
  "ordering_constraints": ["The empty venue must appear before guests arrive"],
  "moments": {
    "required": ["Group reveal"],
    "optional": [],
    "forbidden": ["Visible private information"]
  },
  "deliverable": {
    "target_duration_us": 30000000,
    "max_duration_us": 90000000,
    "width": 1920,
    "height": 1080,
    "aspect_ratio": "16:9",
    "fps": "30/1",
    "audio_hz": 48000
  },
  "pacing": "dynamic",
  "transition_preference": "cuts",
  "audio": {
    "priority": ["voiceover", "source_audio", "music", "ambience", "sfx"],
    "target_lufs": -14,
    "true_peak_dbtp": -1
  },
  "unresolved_choices": []
}

Run the deterministic lifecycle from the skill directory, replacing example paths and identifiers:

python scripts/doctor.py --json > doctor.json
python scripts/project.py init video-projects/demo \
  --brief brief.json --toolchain-lock doctor.json

python scripts/project.py add-input video-projects/demo /absolute/path/clip-01.mp4 \
  --kind video --input-id clip-01 --source-audio candidate
python scripts/project.py add-input video-projects/demo /absolute/path/music.wav \
  --kind audio --input-id music-01 --audio-role music

python scripts/analyze.py video-projects/demo

Initialization stores an immutable copy at revisions/r0001/brief.json. Every later render, QC report, and approval resolves that revision-owned brief rather than a mutable project-wide delivery contract.

The first analysis index has semantic status pending. Codex inspects its contact sheets and machine evidence, writes a complete annotation draft inside the project, and reruns the same analysis selection and settings:

python scripts/analyze.py video-projects/demo \
  --semantic-annotations semantic-draft.json
python scripts/project.py put-artifact video-projects/demo \
  --revision r0001 --artifact-type analysis_index \
  --file /absolute/path/to/complete-analysis-index.json

analysis_index is the canonical artifact kind stored in revision.json; analysis-index is also accepted as a CLI alias, and the file remains analysis-index.json. The command returns the SHA-256 of the canonically stored artifact. Narrative work begins only after this registration. Codex puts that exact digest in the narrative's top-level analysis_index_sha256—not the nested machine_analysis_sha256—and gives every beat evidence item an indexed input_id, required candidate_id, source_start_us, and source_duration_us. It then creates the remaining schema-validated artifacts described in the artifact contract. The approval and render sequence is:

Constant video speed is an explicit storyboard decision, represented as a reduced rational speed: {"num": n, "den": d} plus independent integer source_duration_us and output_duration_us. New artifacts should write all three fields even at 1/1; legacy omissions normalize to identity speed. Ratios are limited to 1/4..8/1, must agree with the durations within one approved output frame, and must match exactly between the approved storyboard and timeline. Video speed never changes independent music, voiceover, ambience, or SFX tracks, and selecting a video clip never includes its embedded audio implicitly.

python scripts/project.py put-artifact video-projects/demo --revision r0001 \
  --artifact-type narrative --file narrative.json
python scripts/project.py approve video-projects/demo --revision r0001 \
  --gate narrative --actor you

python scripts/storyboard.py storyboard-draft.json \
  --output storyboard.html --normalized-output storyboard.json --fps 30/1
python scripts/project.py put-artifact video-projects/demo --revision r0001 \
  --artifact-type storyboard --file storyboard.json
python scripts/project.py approve video-projects/demo --revision r0001 \
  --gate storyboard --actor you

python scripts/project.py put-artifact video-projects/demo --revision r0001 \
  --artifact-type timeline --file timeline.json
python scripts/render.py video-projects/demo --revision r0001 --profile preview
python scripts/qc.py video-projects/demo --revision r0001 --profile preview
python scripts/project.py approve video-projects/demo --revision r0001 \
  --gate rough_cut --actor you
python scripts/render.py video-projects/demo --revision r0001 --profile master
python scripts/qc.py video-projects/demo --revision r0001 --profile master
python scripts/project.py editorial-review video-projects/demo --revision r0001 \
  --actor you --decision approved
python scripts/project.py delivery-ready video-projects/demo --revision r0001
python scripts/project.py verify video-projects/demo

Approval gates

Gate What it confirms Required before
narrative One of at least two full-duration story options is selected, its top-level digest matches the current complete analysis_index, and every evidence range names and stays within an exact semantic candidate. Storyboard storage
storyboard Exact shots, source/output ranges, visible rational speeds, timings, transitions, and audio treatments match the selected narrative. Timeline storage
rough_cut The reviewed preview, exact timeline, validated preview render lock, and current passing QC report are digest-bound together. This locks the revision. Master rendering

Approval is never inferred from silence. Every approval also binds the owning revision's brief digest. Narrative approval rechecks the current input-manifest, index digest, candidate identities, and usable ranges. Stale analysis provenance also makes dependent storyboard and rough-cut approvals non-current. Preview QC refuses a missing or stale render lock and verifies its output, timeline, brief, toolchain, input-manifest, source-map, and implementation hashes before analysis. Rough-cut approval additionally hashes the preview, timeline, render lock, and QC report together; changing any of them blocks master eligibility. Once a narrative has been approved in a revision, its analysis_index cannot be replaced there—even after invalidation—so provenance changes start a child revision. Valid carried indexes retain their bytes and digest, while approvals and renders must be recreated. If source registration changed, create the child with --no-carry-forward and rebuild the index and narrative.

Editorial review remains outside these three gates. The lifecycle recorder accepts approved or changes_requested, refuses non-passing or stale master bundles, and writes an immutable record binding the exact master, QC, render lock, brief, timeline, input manifest, source map, and toolchain. delivery-ready rechecks those bytes and succeeds only for a current approved review. project.py verify permits drafts with no renders, but validates every preview/master bundle and editorial review that does exist.

Create format variants as child revisions. Omitting --brief carries the parent's brief bytes and compatible authoritative artifacts exactly. Supplying a complete brief gives only the child a new delivery contract. Compatible analysis is retained, while a narrative, storyboard, or timeline that no longer matches the new duration or format is dropped together with its downstream creative artifacts so it can be rebuilt safely:

python scripts/project.py new-revision video-projects/demo \
  --change-request "Create a 9:16 social cut" \
  --brief portrait-brief.json

Do not edit project-root brief.json to revise approved work. Older revisions without snapshots use it only as a compatibility fallback.

Optional local acceptance checks

After explicitly installing .[asr], optionally check a new machine and already-local base model with representative local audio from an activated Python 3.11/3.12 environment:

python tools/profile_asr.py --model-dir <local-base> --audio <representative>

The check is local-only, uses faster-whisper base on CPU/int8 with batch size one, and passes only when peak process RSS is strictly below 2,000,000,000 bytes. Require the report to show profile: "faster-whisper-base-cpu-int8-batch-1", downloads_performed: false, and passed: true. This is a manual, resource-heavy acceptance check, not part of normal CI or routine editing.

For no-download pipeline and QC smoke media, synthesize the deterministic fixture catalog with python tools/generate_fixtures.py <empty-output-dir>. It uses local FFmpeg and includes a tone-based voiceover.wav stand-in; use representative real speech, not that tone, for ASR acceptance.

Local-only and no-download policy

The skill does not call third-party APIs, fetch stock media, install packages, or download model weights. FFmpeg, FFprobe, optional analysis libraries, and any faster-whisper model must already exist locally. Transcription accepts only an explicit local model directory and uses local-only loading. Missing optional capabilities are recorded with deterministic fallbacks; missing required capabilities stop the workflow.

Supported scope

Version 1 supports user-supplied source sets up to 30 minutes and music-led SDR H.264/AAC MP4 montages up to 90 seconds and 1080p. It supports hard cuts, simple fades/dissolves, one music bed, optional voiceover, selective source ambience, sound effects, local shot/beat/speech analysis, immutable revisions, and preview/master QC.

Deferred work includes dialogue-first or long-form editing, text-to-video, live streams, motion graphics, titles and captions, stabilization, denoising, automatic reframing, advanced color matching, multicamera sync, NLE interchange, stock-media retrieval, and automatic global sequence optimization. A single trim/transcode or a general FFmpeg question does not need this skill.

See SKILL.md for the operating workflow, editorial heuristics for narrative guidance, and quality gates for delivery checks.

License

Released under the MIT License.

About

Local-first reproducible video editing skill for Codex using Python and FFmpeg

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages