Saving and projects

A project is JSON

Everything the user does is an edit to a Project — plain JSON: the canvas size, the tracks and their items, and the media files they use (assets). Nothing is ever written into the media itself. Projects are validated when they open and carry a file version; older files are upgraded automatically, so a project saved today always opens later.

import { parseProject } from '@video-ultra/core';

const result = parseProject(json); // a string or an object
if (result.ok) open(result.project); // result.warnings: anything that was repaired
else showError(result.error);

Three ways to keep work

  • Autosave (built in, on by default): each edit goes into the browser's private file system, with crash recovery; reopening the editor brings the last project back. Turn it off with autosave={false}.
  • Your storage: onSave(project) runs about a second after each edit. Store the JSON and pass it back as initialProject. This is the durable save — browsers may clear their own storage.
  • Your videos: with autosave on, the top bar's Your videos lets people keep several videos on the device, make a copy of one (the media is shared, not copied), start a new one or delete one. Hide it with customize={{ hide: ['videos'] }} when your app has its own list.

Media files

Imported files are copied into the browser's private storage (in pieces, never all in memory) and the project refers to them by id. To keep media on your side — so a project opens on another device — store the files yourself, give assets a url source and answer resolveMedia:

<VideoEditor
  initialProject={project}
  resolveMedia={async (asset) => {
    if (asset.source.type !== 'url') return null; // let the editor use its own storage
    const response = await fetch(asset.source.url);
    return response.ok ? response.blob() : null;
  }}
/>

Export

People export from the Export button: MP4 (H.264, or HEVC / AV1 where the device can encode them) or WebM, a part of the video, sound only (M4A, Ogg, WAV) or one frame as a picture. You get the files through onExport, onExportAudio and onSaveFrame. Exports run in a worker, stream to disk and can be cancelled.