@omnimedia/omnitool
Version:
open source video processing tools
41 lines • 1.36 kB
JavaScript
import { O } from "./o.js";
import { fps } from "../../units/fps.js";
import { ResourcePool } from "../parts/resource-pool.js";
import { VideoPlayer } from "../renderers/player/player.js";
import { produce } from "../renderers/export/produce.js";
export class Omni {
driver;
resources = new ResourcePool();
constructor(driver) {
this.driver = driver;
}
load = async (spec) => {
return Object.fromEntries(await Promise.all(Object.entries(spec).map(async ([key, value]) => [key, await this.resources.store(await value)])));
};
timeline = (fn) => {
const o = new O({
timeline: {
format: "timeline",
info: "https://omniclip.app/",
version: 0,
items: [],
rootId: 0
}
});
const root = fn(o);
o.timeline.rootId = root.id;
return o.timeline;
};
playback = async (timeline) => {
return new VideoPlayer(this.driver, (hash) => this.resources.require(hash).url, timeline);
};
render = async (timeline, framerate = 30) => {
return produce({
timeline,
fps: fps(framerate),
driver: this.driver,
resolveMedia: (hash) => this.resources.require(hash).url
});
};
}
//# sourceMappingURL=omni.js.map