Making clips

Thumbnails

Make a filmstrip of keyframe thumbnails, painted as each one lands.

createThumbnails(options) makes evenly spaced thumbnails of a source for a filmstrip, handing each to onThumbnail as it's decoded.

const ctx = strip.getContext('2d')
const tile = strip.width / 10

await createThumbnails({
  source: '/video/interview.mp4',
  count: 10,
  onThumbnail: (index, image) => ctx.drawImage(image, index * tile, 0, tile, strip.height),
})
OptionTypeDefaultDescription
sourceBlob | string | URL | HTMLVideoElement-What to read
startnumber0First thumbnail's time
endnumberthe end of the sourceThumbnails stop before this
countnumber10How many
widthnumber160Thumbnail width; the height follows the source
onThumbnail(index, image, time) => void-Each thumbnail as it lands; draw it straight away
signalAbortSignal-Stops reading, cancelling any download in flight

Each thumbnail is the nearest keyframe at or before its time, and thumbnails sharing a keyframe share one decode, so nothing after a keyframe is ever decoded. From an HLS stream, only the smallest variant that covers a thumbnail is read. The picture is reused once onThumbnail returns, so draw or copy it synchronously.

munsonlabs · MIT licensed · © 2026