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

Node / Video Ffmpeg · guide

Transcode, compress & export presets

Current Apexify.js 6.0.0 documentation for Transcode, compress & export presets.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

convert

What it does: Re-encodes the video with a quality preset or explicit bitrate, optional fps and resolution.

Options

FieldRequiredEffect
outputPath✓Destination file. Container is chosen by FFmpeg from the extension (.mp4, .webm, …).
format—Listed in types (mp4/webm/avi/mov/mkv) but not passed as -f in convertVideo — rely on outputPath suffix for mux format.
quality—low → -crf 28, medium → 23, high → 18, ultra → 15. Lower CRF = higher quality, bigger files.
bitrate—kbps for -b:v — overrides the CRF preset when set.
fps—Output frame rate -r. Drops or duplicates frames as FFmpeg sees fit.
resolution—scale=w:h — stretches to exact size (no letterbox in this helper).

Example — archive master to HD MP4

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './master.mov',  convert: {    outputPath: './deliver/hd.mp4',    quality: 'high',    fps: 30,    resolution: { width: 1920, height: 1080 },  },});

Example — fixed bitrate for streaming

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './raw.mp4',  convert: {    outputPath: './stream/meeting.mp4',    bitrate: 3500,    fps: 25,  },});

compress

What it does: Shrinks file size using CRF + encoder preset, or caps max bitrate.

Options

FieldEffect
qualitylow (-crf 32 -preset fast) through ultra (-crf 18 -preset veryslow). medium default — balances size vs time.
maxBitratekbps cap (-b:v -maxrate -bufsize). Wins over CRF-style flags when set.
targetSizePresent in TypeScript — not implemented in compressVideo (ignored today).

Return value

Includes originalSize and compressedSize bytes when stat succeeds.

Example

SOURCEtypescript
typescript
Studio
const out = await painter.createVideo({  source: './huge-screen-recording.mp4',  compress: {    outputPath: './shareable.mp4',    quality: 'medium',    maxBitrate: 2000,  },}); console.log(  `Saved ${((out.originalSize - out.compressedSize) / 1e6).toFixed(1)} MB`);

exportPreset

What it does: Calls convertVideo with fixed resolution, fps, bitrate, and container tuned for a platform.

Presets (from code)

presetResolutionFPSBitrate (kbps)Container
youtube1920×1080308000mp4
instagram1080×1080303500mp4
tiktok1080×1920304000mp4
twitter1280×720305000mp4
facebook1280×720304000mp4
4k3840×21603050000mp4
1080p1920×1080308000mp4
720p1280×720305000mp4
mobile720×1280302500mp4
web1280×720303000webm

Names are case-insensitive.

Options

FieldEffect
presetChooses row above. Unknown preset → throws.
outputPath✓

Supports onProgress.

Example

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './landscape.mp4',  exportPreset: {    preset: 'tiktok',    outputPath: './out/vertical-for-tiktok.mp4',  },  onProgress: (p) => process.stdout.write(`\r${p.percent.toFixed(0)}%`),});

Next steps