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

Node / Video Ffmpeg · guide

Geometry: rotate & crop

Current Apexify.js 6.0.0 documentation for Geometry: rotate & crop.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

rotate

What it does: Applies transpose for 90° steps and/or hflip/vflip.

Options

FieldEffect
angle90 → transpose=1 (clockwise-like mapping used in code); 180 → double transpose; 270 → transpose=2.
fliphorizontal — mirror left/right; vertical — flip upside down; both — apply both.
outputPath✓

You can combine angle and flip.

Example — upright phone video

SOURCEtypescript
typescript
Studio
await painter.createVideo({  source: './phone-vertical.mp4',  rotate: {    angle: 270,    outputPath: './phone-upright.mp4',  },});

crop

What it does: crop=w:h:x:y — keeps a width×height rectangle whose top-left is (x, y) in pixels.

Options

FieldMeaning
x, yOrigin of crop window (pixels from top-left).
width, heightSize of output (pixels).
outputPath✓

Values outside frame bounds will error or clamp depending on FFmpeg — prefer validating against getInfo first.

Example — 16:9 centre crop from 4K

SOURCEtypescript
typescript
Studio
const painter = new ApexPainter();const info = await painter.createVideo({ source: './uhd.mp4', getInfo: true }); const targetW = 1920;const targetH = 1080;const x = Math.floor((info.width - targetW) / 2);const y = Math.floor((info.height - targetH) / 2); await painter.createVideo({  source: './uhd.mp4',  crop: {    x,    y,    width: targetW,    height: targetH,    outputPath: './hd-centre.mp4',  },});

Next steps