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

Node / Video Ffmpeg · guide

Transcode, trim & geometry

Current Apexify.js 6.0.0 documentation for Transcode, trim & geometry.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

See also: Transcode & export presets · Timeline edits · Geometry.


convert

Re-encodes with CRF presets or explicit video bitrate.

OptionRequiredNotes
outputPath✓Container inferred from extension (FFmpeg default muxer).
format—Declared in types (mp4, webm, …) — not forwarded as -f in current convertVideo; rely on outputPath suffix (e.g. .webm).
quality—low (-crf 28), medium (23), high (18), ultra (15). Default medium.
bitrate—kbps video (-b:v …k) — wins over CRF when set.
fps—-r output frame rate.
resolution—-vf scale=w:h.

Example — web-friendly MP4

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

Example — capped bitrate

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './raw.mp4',  convert: {    outputPath: './small.mp4',    bitrate: 2500,    fps: 24,  },});

trim

Stream copy slice (-c copy) from startTime for endTime - startTime seconds.

FieldNotes
startTime, endTimeSeconds (absolute end marker).
outputPathDestination path.

Example

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './long.mp4',  trim: {    startTime: 60,    endTime: 125,    outputPath: './highlight.mp4',  },});

compress

CRF-based shrink or hard bitrate cap.

OptionNotes
qualitylow … ultra maps to -crf + -preset (fast → veryslow). Default medium.
maxBitratekbps triplet -b:v -maxrate -bufsize.
targetSizePresent on type — not applied in compressVideo today (reserved).

Returns { outputPath, success, originalSize?, compressedSize? }.

Example

SOURCEtypescript
typescript
Studio
const stat = await painter.createVideo({  source: './big.mp4',  compress: {    outputPath: './lite.mp4',    quality: 'low',    maxBitrate: 1200,  },});console.log(stat.originalSize, stat.compressedSize);

rotate

Right-angle transpose + optional flips.

OptionValues
angle90, 180, 270 — transpose chain.
fliphorizontal (hflip), vertical (vflip), both.
outputPath✓

Example

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './phone.mp4',  rotate: {    angle: 270,    flip: 'horizontal',    outputPath: './corrected.mp4',  },});

crop

-vf crop=w:h:x:y (width/height/top-left).

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './wide.mp4',  crop: {    x: 320,    y: 180,    width: 1280,    height: 720,    outputPath: './tight.mp4',  },});

changeSpeed

Video setpts, audio atempo chain when audio exists (chained atempo >2× / <0.5×).

FieldNotes
speed>1 faster, <1 slower.
outputPath✓
SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './demo.mp4',  changeSpeed: { speed: 1.5, outputPath: './demo-fast.mp4' },});

createTimeLapse

Alias → changeVideoSpeed with speed (default 10).

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './clouds.mp4',  createTimeLapse: { speed: 20, outputPath: './clouds-tl.mp4' },});

reverse

-vf reverse -af areverse — heavy; needs FFmpeg decode of full stream.

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './clip.mp4',  reverse: { outputPath: './clip-rev.mp4' },});

replaceSegment

Splices replacement media into [targetStartTime, targetEndTime] of source.

Exactly one replacement source:

ModeFields
Clip from another videoreplacementVideo, optional replacementStartTime, replacementDuration (defaults to gap length).
Frame sequencereplacementFrames (paths/buffers), replacementFps (default 30) → internal createVideoFromFrames.

Validates window vs parent duration; concatenates part1 | replacement | part3 with -c copy.

Example — overlay B-roll

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './main.mp4',  replaceSegment: {    targetStartTime: 10,    targetEndTime: 18,    replacementVideo: './broll.mp4',    replacementStartTime: 0,    replacementDuration: 8,    outputPath: './main-edited.mp4',  },});

freezeFrame

Inserts a held still of time lasting duration seconds mid-timeline.

FieldNotes
timeFreeze capture instant (seconds).
durationHold length on output.
outputPath✓

Supports onProgress on final concat.

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './pitch.mp4',  freezeFrame: {    time: 12,    duration: 3,    outputPath: './pitch-pause.mp4',  },  onProgress: (p) => console.log(Math.round(p.percent)),});

Next steps