Crop
crop cuts the largest window of an aspect out of the frame, centred on a focus point and kept inside the frame.
await createSplice({
source,
start,
end,
crop: {
aspect: '9:16',
focus: { x: 0.3 },
},
})
| Option | Type | Default | Description |
|---|---|---|---|
aspect | `${number}:${number}` | - | The target aspect, such as '9:16', '4:5' or '1:1' |
focus | { x?: number; y?: number } | { x: 0.5, y: 0.5 } | The window's centre, each axis from 0 (left or top) to 1, held so the window never leaves the frame |
height | number | at least 1920 for 9:16 | The output height in pixels, in either direction |
Without crop, the whole frame is kept.
Output size
By default the output is the window's own size or the largest frame of its aspect that fits 1080x1920 (1920x1080 for landscape), whichever is bigger: 9:16 of 720p or 1080p is 1080x1920, 1:1 is 1080x1080, and 9:16 of 4K keeps its own 1214x2160. Small windows are scaled up so captions, the end card and the stamp are drawn sharp; frames are scaled with high-quality smoothing.
Why the whole frame is drawn
The crop is made by drawing the whole frame offset and scaled so the canvas edges cut it. Drawing a source rectangle of a video frame doesn't work in WebKit, which ignores the rectangle and draws the whole frame squashed. A phone video's rotation is applied as it's drawn, so it arrives upright.