Implementation:0xsline OpenChatCut ProbeVideo
| Knowledge Sources | |
|---|---|
| Domains | Media_Analysis, Media_Import, Encoding |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Concrete function that probes a video file with FFprobe to extract metadata (dimensions, codecs, bitrate, frame rate, VFR detection) used to decide the normalization plan.
Description
The probeVideo function runs `ffprobe -show_streams -show_format -of json` and extracts a `ProbeMeta` object with:
- Display dimensions: Width/height adjusted for rotation side-data (portrait footage stored landscape-coded with rotation metadata gets swapped).
- Duration and size: From the format container.
- Source bitrate: From video stream, format, or computed from size/duration as fallback.
- Frame rates: Both `avgFrameRate` and `nominalFrameRate` parsed from rational strings.
- Variable frame rate detection: True when avg and nominal FPS differ.
- Codecs: Video and audio codec names.
- Audio presence: Boolean flag.
- Frame count: From `nb_frames` if available.
This is distinct from parseProbe — `probeVideo` is the server-side probe for the normalization pipeline (includes bitrate and VFR details), while `parseProbe` is the pure parser for general media inspection (includes quality-risk heuristics).
Usage
- Normalization pipeline: Called before `encodeNormalized` to determine the transcoding plan.
- Bitrate recommendation: `recommendedBitrate` uses `ProbeMeta` to compute target bitrate.
Code Reference
Source Location
- Repository: OpenChatCut
- File:*** server/media-normalization.ts
Signature
export interface ProbeMeta {
width: number;
height: number;
duration: number;
videoCodec: string;
audioCodec: string;
hasAudio: boolean;
sourceBitrate: number;
size: number;
avgFrameRate?: number;
nominalFrameRate?: number;
frameCount?: number;
variableFrameRate: boolean;
}
export async function probeVideo(path: string, signal?: AbortSignal): Promise<ProbeMeta>;
Import
import { probeVideo, type ProbeMeta } from '../server/media-normalization.ts';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| path | string | Yes | Path to the video file |
| signal | AbortSignal | No | Cancellation signal |
Outputs
| Name | Type | Description |
|---|---|---|
| ProbeMeta | object | Video metadata with dimensions, codecs, bitrate, FPS, VFR flag |
Usage Examples
Probe Before Normalization
import { probeVideo } from '../server/media-normalization.ts';
const meta = await probeVideo('/media/uploads/source.mp4');
console.log(`${meta.width}x${meta.height}, ${meta.duration}s`);
console.log(`Codec: ${meta.videoCodec}, Bitrate: ${meta.sourceBitrate}`);
console.log(`VFR: ${meta.variableFrameRate}`);