Skip to main content

opencontext-video

The OpenContext media processing worker. It ingests uploaded videos, still images, image sets, and PDFs, then runs the media-to-context pipeline: extracting audio and frames, rendering PDF pages, transcribing speech when present, applying vision and OCR, aligning results on a shared timeline, and producing evidence-linked developer context.

The worker polls the OpenContext API, processes jobs through resumable stages, and stores timestamped transcript, visual, and OCR evidence in the result payload. Text claims carry stable evidence IDs and certainty labels in both Markdown and JSON exports.

Install

pip install opencontext-video

For local speech recognition:

pip install "opencontext-video[local]"

The local extra pins PyAV below 19 because Faster Whisper 1.2.1 still passes the removed metadata_errors argument to av.open(). Remove the pin after Faster Whisper publishes a release compatible with PyAV 19+.

CLI

Analyze a local video without running the web app or database:

opencontext analyze video.mp4 --out context.md --json context.json

Still images use the same command and output contract:

opencontext analyze mockup.png --out context.md --json context.json

PDFs up to 30 pages use the same output contract and combine embedded text with rendered-page vision evidence:

opencontext analyze reference.pdf --out context.md --json context.json

The web upload flow can submit up to 10 images as one ordered image-set job with cross-image comparisons. CLI batch mode analyzes each file independently and keeps collision-safe per-file outputs.

Use --offline to run the full extraction and export path with clearly labeled fixture transcription and vision output:

opencontext analyze video.mp4 --offline --out context.md --json context.json

The CLI accepts LOW, MEDIUM, or HIGH via --detail-level, and provider overrides via --transcription-provider, --vision-provider, and --text-provider.

Analyze every supported file in a directory:

opencontext analyze ./recordings --output-dir ./context --offline

Batch mode writes collision-safe <name>.md and <name>.json pairs and prints a JSON summary with success and failure counts. It continues after an invalid input, preserves outputs that already succeeded, and exits non-zero when any item fails. Use --quiet to suppress the summary.

Turn an existing result into a repository-aware implementation brief:

opencontext brief context.json --repo ../my-app \
  --task "Implement the recorded settings flow" --out implementation-brief.md

The brief preserves evidence IDs, detects repository languages and manifests, and separates observed behavior from inferred or uncertain claims.

Score a context result against a ground-truth evaluation item:

opencontext evaluate context.json \
  --truth docs/evaluation/fixture-dataset.json \
  --model-name fixture --model-version 1 \
  --measurement-kind fixture-baseline --out evaluation.json

The report includes transcript WER/CER, OCR precision/recall/F1, and visual keyword recall. Fixture, smoke-test, and measured runs remain separately labeled.

Check the local runtime and configured providers before submitting a job:

opencontext doctor --offline
opencontext doctor --offline --json

The report labels each item OK, MISSING, or UNVERIFIED without printing API keys or tokens. Network checks are opt-in with --check-network and use a three-second timeout. --json emits one document containing an overall ok value and ordered checks for setup scripts and CI preflight checks.

When configuring TRANSCRIPTION_PROVIDER=faster_whisper as in .env.example, install the local extra alongside dev:

cd workers/processor
python -m venv .venv
# Windows
.venv/Scripts/python -m pip install -e ".[dev,local]"
.venv/Scripts/python -m oc_worker.main
# macOS/Linux
.venv/bin/python -m pip install -e ".[dev,local]"
.venv/bin/python -m oc_worker.main

Use --once to claim and process at most one job, which is useful for integration tests and cron-style deployments:

python -m oc_worker.main --once

Set WORKER_API_TOKEN to the same value used by the web app before starting the worker. Provider settings are read from the worker process environment.

Local providers

  • TRANSCRIPTION_PROVIDER=faster_whisper runs speech recognition locally; install the local extra and allow the first model download.
  • TRANSCRIPTION_PROVIDER=openai_audio sends extracted WAV audio to an audio-capable OpenAI-compatible chat model through the same OPENAI_BASE_URL and API-key settings used for hosted vision.
  • VISION_PROVIDER=ollama remains available for a local Ollama server.
  • VISION_PROVIDER=openai_compatible can call OpenCode Go with OPENAI_BASE_URL=https://opencode.ai/inference/go/openai/v1, OPENCODE_API_KEY, and an image-capable VISION_MODEL. Each claimed job receives an independent x-opencode-session identifier so one job cannot exhaust another job's session quota or share conversation state.
  • VISION_PROVIDER=gemini uses GEMINI_API_KEY, an image-capable VISION_MODEL, and GEMINI_BASE_URL for native Gemini image analysis. VISION_TIMEOUT_SECONDS bounds the request.
  • VISION_CONCURRENCY bounds simultaneous image analysis calls. Use 1 for rate-limited upstream accounts. Transient provider errors retry up to three times with short backoff. A longer Retry-After defers the whole job so the worker can continue with other queued work.
  • VISION_MAX_FRAMES sets the maximum number of evenly sampled video/PDF frames sent to the vision provider per job (default 60). Image sets are already limited to 10 source images.
  • FRAME_SAMPLING_MODE=hybrid combines scene cuts with interval sampling. For videos in that mode, a conservative Python pass removes only adjacent frames whose 64-bit difference hash and normalized pixel RMS both match the prior retained frame. The first and final frames always survive, fingerprint failures fail open, and image sets are never merged. Tune FRAME_DEDUP_HASH_DISTANCE and FRAME_DEDUP_PIXEL_RMS only from measured evidence-loss results; see the benchmark.
  • OCR_PROVIDER=tesseract extracts text independently with the local Tesseract binary. OCR_PROVIDER=vision keeps the compatibility behavior of deriving OCR rows from the vision provider's visibleText.
  • TRANSCRIPTION_PROVIDER=fixture and VISION_PROVIDER=fixture provide deterministic, clearly labeled output for offline tests. They do not run speech recognition or computer vision and should not be used to claim real analysis quality.

The generated-media integration tests in tests/test_e2e_fixture.py invoke real FFmpeg and PDFium for probing, audio and frame extraction, still-image conversion, image sets, and PDF page rendering, while using fixture providers for inference.

Real OpenCode Go vision smoke test

The hosted vision test is opt-in because it calls an external API:

export OPENCODE_API_KEY=...
export OPENAI_BASE_URL=https://opencode.ai/inference/go/openai/v1
export VISION_MODEL=hy4-flash-free
OPENCONTEXT_OPENCODE_E2E=1 pytest tests/test_opencode_vision_smoke.py -q

The test verifies the model catalog accepts image input, analyzes a generated frame, and runs a synthetic checkout reference through the full image pipeline. It requires the model to recover at least two of the expected UI/OCR labels. This is a setup smoke test, not evidence of broad model quality.

Real OpenCode Go audio smoke test

export OPENCODE_API_KEY=...
export OPENAI_BASE_URL=https://opencode.ai/inference/go/openai/v1
export TRANSCRIPTION_MODEL=mimo-v2.6-pro
OPENCONTEXT_OPENCODE_AUDIO_E2E=1 pytest tests/test_opencode_audio_smoke.py -q

This checks model-catalog audio support and transcribes the attributed Harvard sentence recording committed under docs/evaluation/.

MCP server

Install the agent extra:

pip install "opencontext-video[agent]"
opencontext-mcp

The stdio MCP server exposes:

  • analyze_media — analyze a local video or image and return an evidence-linked brief.
  • analyze_video and analyze_image — explicit compatibility entry points.
  • implementation_brief — convert an existing context JSON result into a brief.
  • context_evidence — return the bounded evidence ledger.

Example client configuration:

{
  "mcpServers": {
    "opencontext": {
      "command": "opencontext-mcp",
      "args": []
    }
  }
}

Metadata

Release files for opencontext-video 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opencontext-video 0.1.2
File Size Uploaded Provenance Actions
opencontext_video-0.1.2.tar.gz 154.6 kB With provenance Details for opencontext_video-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opencontext-video 0.1.2
File Interpreter ABI Platform Actions
opencontext_video-0.1.2-py3-none-any.whl Python 3 none any Details for opencontext_video-0.1.2-py3-none-any.whl

Total release size: 268.2 kB

Release files / opencontext_video-0.1.2.tar.gz

Download URL opencontext_video-0.1.2.tar.gz
Size 154.6 kB
Tags Source
SHA-256 checksum
How to use checksums
082f822c8f41b8bc071470451ead7176a10aea6ad1a767c75d900a626c8535e7
BLAKE2b-256 checksum
How to use checksums
72b833db37954c73046a5c81467a71a69faaece1602a035524ca1dfbdadbf6a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / opencontext_video-0.1.2-py3-none-any.whl

Download URL opencontext_video-0.1.2-py3-none-any.whl
Size 113.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ad022e721c46ecdbaa9219e18060bb98d4d04e0f8cb50180ca769565bfff5a1
BLAKE2b-256 checksum
How to use checksums
8a6768f121feed90d7785da4d95018fff14c621bdbf4ad724f0e6f88e43c58f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for opencontext-video 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opencontext_video-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page