Skip to content
Apexify.jsDocs
Apexify.js version v5.4.5

Node / Video Ffmpeg · guide

onProgress callback

Current Apexify.js 6.0.0 documentation for onProgress callback.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

onProgress is one of the shared Phase 8 video execution controls. FFmpeg-backed operations use FFmpeg's machine-readable -progress pipe:2 output rather than scraping human-formatted status lines.

Type

SOURCEtypescript
typescript
Studio
onProgress?: (progress: {  percent: number;  time: number;   // encoded position, seconds  speed: number;  // e.g. 2.3 means ~2.3× realtime}) => void;

Where it applies

Pass onProgress at the top level of VideoCreationOptions:

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './input.mp4',  trim: {    startTime: 10,    endTime: 40,    outputPath: './clip.mp4',    mode: 'accurate',  },  onProgress: ({ percent, time, speed }) => {    process.stdout.write(`\r${percent.toFixed(1)}%  ${time.toFixed(2)}s  ${speed.toFixed(2)}x`);  },});

The same callback is forwarded by FFmpeg-backed conversion, trim, compositing, audio, overlay, frame-output, transition, and other render operations that execute through the shared video runtime.

Metadata-only work such as getInfo/ffprobe does not manufacture FFmpeg encode progress. Very short FFmpeg jobs may also finish before many progress records are emitted.


Pipeline progress

videoPipeline().render() accepts the same control:

SOURCEtypescript
typescript
Studio
const result = await painter  .videoPipeline('./input.mp4')  .trim(0, 15)  .text({    text: 'Apexify',    x: 32,    y: 32,    startTime: 0,    endTime: 4,    font: { size: 36, family: 'Arial' },    fill: { color: '#ffffff' },  })  .render({    outputPath: './out.mp4',    onProgress: ({ percent }) => console.log(percent),  }); console.log(result.passes, result.executionPlan);

A pipeline can contain several FFmpeg passes. The callback reports the active pass's FFmpeg progress; use result.executionPlan and result.passes after rendering to inspect the deterministic pass plan that actually ran.


SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './input.mp4',  convert: { outputPath: './out.mp4' },  signal: controller.signal,  timeoutMs: 120_000,  overwrite: false,  onProgress: handleProgress,});
  • signal aborts active work where applicable.
  • timeoutMs bounds the FFmpeg process.
  • overwrite: false rejects an existing output rather than replacing it.
  • onProgress observes the active FFmpeg process without changing output semantics.

Behaviour and limits

percent is derived from FFmpeg's reported encoded time against the operation's expected duration when that duration is known. It is operational progress, not a promise of frame/sample-level completion accuracy. Filters, muxer flushes, multi-pass pipeline stages, and very short clips can make updates uneven.

The callback should stay lightweight. If your application needs persistence, queue or throttle writes instead of performing expensive synchronous work on every progress record.


Next steps