Introduction
feat/splice branch.@munsonlabs/splice turns the video someone is watching into a short clip they can share, without a server. It trims a range, crops it to 9:16 (or any aspect), burns the captions into the picture, stamps your logo in a corner, adds an end card that sends viewers back to the article, and writes an MP4, all with WebCodecs on the viewer's device. Mediabunny reads and writes the containers; splice adds the cropping, captions, overlays and output planning.
import { canSplice, createSplice } from '@munsonlabs/splice'
const check = await canSplice(src)
if (check.ok) {
const clip = await createSplice({
source: src,
start: 42,
end: 52,
crop: { aspect: '9:16' },
captions: '/video/interview.en.vtt',
origin: {
url: location.href,
title: document.title,
publisher: 'Example News',
},
endCard: {},
})
}
Try it
Press the scissors in the player, pick a range, drag the crop window over the picture to reframe, then export and play or download the clip. Nothing leaves your browser. The player has deep-link on, so the clip's link reopens this page at that moment, looping the range.
Loading…
What you get
| Entry | What it is |
|---|---|
@munsonlabs/splice | createSplice, canSplice, createThumbnails, createClipLink and planOutput |
@munsonlabs/splice/vue | SpliceEditor, a ready-made inline "clip this" editor in Vue, on the page's video-player |
@munsonlabs/splice/element | <ml-splice-editor>, the same editor as a custom element, for pages without Vue |
@munsonlabs/splice/style | The editor's stylesheet |
Mediabunny is about 157 KB gzipped, so splice is built to load late: the editor imports the core when it first opens. The core is framework-free; the editor needs Vue and @munsonlabs/video-player, which most pages that clip already have.