@pneuma-craft/video
v0.6.0
Published
Video engine — decode, composite, preview, export (built on MediaBunny)
Maintainers
Readme
@pneuma-craft/video
Video engine for pneuma-craft — decode, composite, preview, and export. Built on MediaBunny (WebCodecs) for I/O, with self-built Canvas 2D compositor and Web Audio scheduler for playback.
bun add @pneuma-craft/videoWhat's in here
- Decoder — MediaBunny
Input+CanvasSink/AudioBufferSink - Compositor — Canvas 2D layer compositor with transforms, opacity, blend modes
- Audio scheduler — Web Audio graph with
AudioContext.currentTimeas master clock; drift-corrected against video - Preview engine — drives a rAF loop to play a
@pneuma-craft/timelinecomposition - Exporter — renders frame-by-frame via WebCodecs
VideoEncoder, mixes audio viaOfflineAudioContext, muxes via MediaBunnyOutput - Pluggable subtitle renderer — shared between preview and export
Playback transport semantics
PlaybackEngine follows the HTML media element for the end of the timeline, so
a Play button needs no special-casing:
- The rAF loop pauses at
currentTime === duration(unless aloopregion is set), andengine.endedbecomestrue. play()whileendedrewinds to0and restarts from the top — one cleanpaused→playingtransition, no one-frame flicker.play()on a zero-duration composition is a no-op and leavesstatealone.- Read
engine.ended(mirrored asusePlayback().endedin@pneuma-craft/react) to render a replay affordance instead of comparingcurrentTimeagainstdurationyourself.
Browser support
Requires WebCodecs (VideoDecoder/VideoEncoder) and modern Canvas 2D. Tested on Chromium-based browsers and Safari Tech Preview.
Documentation
See the pneuma-craft repository for the full design spec, architecture, and usage examples.
License
MIT © Pandazki
