Skip to main content

Provenance-first video normalization toolkit for ingest, crop, and web optimization

Project description

Cosmos

CI Docs PyPI

Cosmos is a provenance-first video normalization toolkit for agent and human media pipelines.

It turns heterogeneous camera/video inputs into deterministic, web-ready derivatives and emits machine-joinable sidecars so downstream systems can trust, trace, and reproduce each asset.

Cosmos is designed for both operators and automation:

  • cosmos CLI for ingest/crop/optimize/provenance workflows
  • cosmos.sdk for stable Python integration
  • run-level and artifact-level provenance sidecars for reproducibility

Scope today

  • First-class adapter for COSM camera ingest workflows (manifest-aware processing)
  • General MP4 post-processing surfaces for crop, preview, optimize, and provenance lookup
  • Deterministic CLI contracts suitable for unattended agent execution

The near-term direction is to add more ingestion adapters while keeping the same normalized output and provenance contracts.

Documentation

Agent skill (recommended for agent operators)

Cosmos keeps a canonical in-repo skill package that should be consulted before changing CLI, SDK, ffmpeg policy, provenance fields, or release behavior.

Install

  • Production: pip install polli-cosmos
  • Development (uv):
uv venv .venv
. .venv/bin/activate
uv pip install -e ".[dev]"

CLI quickstart

cosmos --help
cosmos ingest run --help
cosmos crop run --help
cosmos optimize run --help
cosmos crop preview --help

Common workflows

1) Ingest camera outputs

make run.ingest IN=/path/to/raw OUT=./out YES=1

2) Crop MP4 views with jobs JSON

make run.crop INPUT=/path/to/clip.mp4 OUT=_work/out JOBS=_work/job.json YES=1

3) Generate crop previews (contact sheets + stacked overlays)

cosmos crop preview \
  --input /path/to/clip.mp4 \
  --jobs-file _work/job.json \
  --out _work/preview \
  --frame start --frame mid \
  --stack-time 0 \
  --yes

4) Optimize MP4s for web delivery

# Faststart remux (default mode=auto, no transform flags)
cosmos optimize run --input /path/to/clip.mp4 --out-dir _work/web --yes

# Explicit transcode
cosmos optimize run \
  --input /path/to/clip.mp4 \
  --out-dir _work/web \
  --mode transcode \
  --target-height 1080 --fps 30 --crf 23 \
  --yes

5) Inspect provenance mapping

make run.provenance DIR=_work/out

Crop jobs semantics

Crop jobs accept either offsets or centers:

  • Recommended: offset_x, offset_y in [-1, 1] relative to available margin
    • 0 is centered
    • positive values move right/down
    • negative values move left/up
  • Alternative: center_x, center_y in [0, 1]
  • Do not combine offsets and centers in a single job.

Other common fields:

  • targets: one or more square output sizes
  • trim_unit: "time", trim_start, trim_end for bounded crops

Provenance and stable IDs

  • Clip IDs: clip-<stem>-<sha8>
  • View IDs: view-<stem>-<sha8>
  • Optimize sidecars: *.mp4.cosmos_optimized.v1.json

Core join behavior:

  • view.source.sha256 == clip.output.sha256

See docs/provenance.md for full schema links and examples.

Encoder policy (cross-platform)

  • macOS: h264_videotoolbox -> libx264
  • Linux: h264_nvenc -> h264_qsv -> h264_vaapi -> libx264
  • Windows: h264_nvenc -> h264_qsv -> h264_amf -> libx264

Cosmos runtime-probes auto-selected hardware encoders and falls back to libx264 if the host advertises an encoder that is not actually usable.

Developer workflow

make uv-sync
make fmt
make lint
make typecheck
make test

Optional local E2E lanes

  • Slim ingest repro: make e2e-repro-slim
  • 8K windowed repro: make e2e-repro-8k
  • Full heavy repro: make e2e-repro-full

These are fixture-gated and intentionally off for standard CI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polli_cosmos-0.6.0-py3-none-any.whl (68.5 kB view details)

Uploaded Python 3

File details

Details for the file polli_cosmos-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: polli_cosmos-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 68.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for polli_cosmos-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2b994f350d28906ce68772fa03debe67f28dbb1b59470435cdf9653ee607d3e
MD5 b97e8d41c8a26676c5f9fccedd79745d
BLAKE2b-256 23e3b9fc66d33f47e9cc8058f026b0dc710e454fa0cce02b8e4151dd115eb695

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page