Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xsline OpenChatCut ProbeMediaFile

From Leeroopedia
Knowledge Sources
Domains Media_Analysis, Media_Import, Probing
Last Updated 2026-10-22 14:00 GMT

Overview

Concrete function that runs `ffprobe` on a local media file and returns the raw JSON output, plus a Vite plugin exposing the probe over HTTP.

Description

The probeMediaFile function executes `ffprobe -show_streams -show_format -of json` on a local file and returns the parsed JSON record. It is the low-level probe primitive — the raw output is typically passed to parseProbe for normalization.

Key behaviors:

  • Local files: Runs ffprobe directly on the file path.
  • Remote files: `probeResolvedSource` downloads remote URLs through the SSRF-safe fetcher to a temp directory before probing.
  • Source resolution: `resolveProbeSource` classifies a source string as local upload, remote URL, or product asset.
  • HTTP endpoint: `probeMediaPlugin` exposes `POST /api/probe-media` with a `source` field.
  • Timeouts: 30s for local, 90s for remote downloads.

Usage

  • Media import: Called during the probing stage of the import pipeline.
  • Export media resolution: Used to verify media during export materialization.
  • Agent tool: Exposed as an HTTP endpoint for agent media inspection.

Code Reference

Source Location

  • Repository: OpenChatCut
  • File:*** server/plugins/probe-media.ts

Signature

export async function probeMediaFile(path: string): Promise<Record<string, unknown>>;

export async function probeResolvedSource(
  source: Exclude<ProbeSource, { error: string }>,
): Promise<Record<string, unknown>>;

export function probeMediaPlugin(): Plugin;

Import

import { probeMediaFile, probeMediaPlugin } from '../server/plugins/probe-media.ts';

I/O Contract

Inputs

Name Type Required Description
path string Yes Absolute path to the local media file
source (HTTP) string Yes `/media/uploads/<name>`, public URL, or product asset path

Outputs

Name Type Description
probeMediaFile() returns Record<string, unknown> Raw ffprobe JSON (streams, format)

Usage Examples

Probe a Local File

import { probeMediaFile } from '../server/plugins/probe-media.ts';
import { parseProbe } from '../shared/media-probe.ts';

const raw = await probeMediaFile('/media/uploads/abc123.mp4');
const probe = parseProbe(raw);
console.log(`${probe.width}x${probe.height} @ ${probe.fps}fps`);
console.log('Quality risks:', probe.qualityRisks);

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment