Node / Video Ffmpeg · guide
Imperative video helpers (painter.)
Current Apexify.js 6.0.0 documentation for Imperative video helpers (painter.).
Besides createVideo({ ... }), ApexPainter exposes direct probe and frame-extraction methods. These methods use the same central FFmpeg session, validation, runtime limits, remote-network policy, abort/process handling, and isolated temporary workspaces as the rest of the video stack.
Requirements: FFmpeg and ffprobe must be available on PATH, configured through configureApexifyRuntime({ ffmpeg: ... }), or supplied through the documented APEXIFY_FFMPEG_PATH / APEXIFY_FFPROBE_PATH environment variables.
Method map
| Method | Result |
|---|---|
getVideoInfo(source, skipFfmpegCheck?) | Probed video metadata |
extractFrameAtTime(source, seconds, format?, quality?) | One JPEG/PNG Buffer |
extractFrameByNumber(source, frameNumber, format?, quality?) | One JPEG/PNG Buffer; frame numbers are 1-based |
extractMultipleFrames(source, times, format?, quality?) | Ordered Buffer[] |
extractFrames(source, options) | Extracted frame file descriptors { source, isRemote }[] |
extractAllFrames(source, options?) | { source, frameNumber, time }[] |
The same helpers are available through the grouped painter.video stack where documented by its public type surface.
getVideoInfo(source, skipFfmpegCheck?)
source may be a local path, an HTTP(S) URL permitted by the central network policy, or a Buffer. Remote/buffer inputs are staged inside the operation's isolated temporary workspace. Do not depend on any internal temporary pathname.
skipFfmpegCheck defaults to false. It exists for already-validated internal/delegated flows; normal application code should leave it omitted.
Probe failures use the structured Apexify process/input error paths rather than a documented null sentinel contract.
extractFrameAtTime
Signature:
Defaults are outputFormat = 'jpg' and quality = 2. quality must be an integer from 1 through 31. The timestamp must be finite, non-negative, inside the governed video duration, and inside the actual source duration.
extractFrameByNumber
frameNumber is 1-based. The implementation probes FPS and converts the requested frame to (frameNumber - 1) / fps. The frame number must be a positive integer; format and quality use the same validation as extractFrameAtTime.
extractMultipleFrames
This returns an ordered Buffer[]. The timestamp array must be non-empty, each timestamp must be finite and non-negative, and the request is bounded by both collection and maxVideoExtractedFrames limits. Extraction is performed through the shared frame operation/runtime rather than an unbounded Promise.all fan-out.
extractFrames(source, options)
interval is required and is expressed in milliseconds; sampling FPS is derived as 1000 / interval. frameSelection.start and .end are zero-based indexes into the generated sampling sequence and must form an increasing range inside that sequence.
Current options include:
| Field | Behavior |
|---|---|
interval | Required positive sampling interval in milliseconds |
outputFormat | jpg by default; png supported |
quality | JPEG quality value, integer 1–31; default 2 |
frameSelection | Optional bounded start/end generated-frame indexes |
outputDirectory | Destination directory; defaults to ./extracted-frames |
The method writes the selected frames to the output directory and returns local descriptors { source, isRemote: false }[]. The operation's temporary input workspace is isolated and cleaned separately; output files intentionally persist because they are caller-visible results.
The number of extracted files is bounded by maxVideoExtractedFrames.
extractAllFrames(source, options?)
Defaults:
| Option | Default |
|---|---|
outputFormat | png |
outputDirectory | ./extracted-frames |
quality | 2 |
prefix | frame |
startTime | 0 |
endTime | source duration |
The prefix must be a simple filename prefix, the time range must be inside the source duration, and the estimated frame count is checked against maxVideoExtractedFrames before FFmpeg runs. Results are { source, frameNumber, time }[] with zero-based frameNumber metadata.
Disk warning: extracting every frame from a long/high-FPS source can produce substantial persistent output. Use an explicit output directory with sufficient quota and prefer interval/timestamp extraction when full-frame dumping is unnecessary.
Security, cleanup, and cancellation
All direct helpers inherit the Phase 8/13 video runtime controls:
- remote HTTP(S) inputs pass through DNS/SSRF validation, redirect revalidation, transfer-byte limits, and remote concurrency bounds;
- FFmpeg/ffprobe use argv execution with
shell: false; - temporary operation state lives in isolated
fs.mkdtemp()workspaces and is cleaned by default; - custom temp roots come from explicit/session settings, runtime
temp.rootDirectory,APEXIFY_TEMP_DIR, then the OS temp directory; - process timeouts and
AbortSignalcontrols are handled through the shared FFmpeg session where the enclosing API exposes controls; - caller-visible
outputDirectoryfiles fromextractFrames/extractAllFramesare outputs, not temporary workspace files, and are not automatically deleted.
See Security & deployment and Runtime validation & resource governance for the complete policy.
Choosing the surface
Use createVideo() for the typed one-operation router, videoPipeline() for multi-step declarative editing, and these direct helpers when the task is specifically probing or extracting frames.
See also: Frame extraction suite · Metadata & frames · Video pipeline.