How omni-media/omniclip works
Project type and purpose
• Omniclip is an in-browser, open-source video editing web application/library delivered as a set of Web Components.
• It has no central server-side component: all processing (editing, rendering, encoding) happens in the browser using modern APIs (WebCodecs, WebAssembly, Web Workers, OPFS, WebRTC for collaboration).
File structure
• Top-level “s/” directory holds all TypeScript source, split into:
• components/ (custom elements for UI panels: landing page, timeline, media, filters, transitions, text, etc.)
• views/ (lower-level view logic and styling for each UI domain)
• context/ (state management: actions, controllers for collaboration, compositor, media, project, timeline, video-export, shortcuts, store)
• tools/ and utils/ (helper libraries: mp4 parsing, hash router, JSON storage proxy, dashify, etc.)
• Configuration files: tsconfig.json, package.json, GitHub workflows (CI/CD).
README insights
• Unidirectional data flow: Actions → State → Controllers → Components/Views.
• Tech stack: TypeScript, WebCodecs, WebAssembly (MediaInfoModule.wasm), WebRTC, FFmpegHelper (in WASM or Workers), mp4box.js, @benev/slate for rich text.
• No back-end: all storage uses browser storage (OPFS, IndexedDB via FileSystemHelper) and collaboration via WebRTC peers.
Main components
a. UI Layer (blue):
• Web Components (s/components/*)
• View modules (s/views/*)
• User interactions (mouse/keyboard events)
b. State & Action Layer (green):
• Actions dispatcher (s/context/actions.ts)
• Central store (s/context/store/store.ts and state.ts)
c. Controller Layer (orange):
• Collaboration Controller (WebRTC signaling, compressors, message-handling, OPFS manager)
• Timeline Controller (drag-and-drop, effect placement, filmstrip)
• Compositor Controller (animation, filters, text, transition managers, video/audio/image managers)
• Media Controller (media loading, WebCodecs decoding)
• Video-Export Controller (FFmpegHelper, encode_worker, decode_worker, BinaryAccumulator, FPSCounter)
• Project Controller
• Shortcuts Controller
d. Services & Workers (purple):
• Web Workers (compositor.worker.ts, export workers)
• WebAssembly module (MediaInfoModule.wasm)
• mp4box.js adapter
• OPFS (FileSystemHelper) and IndexedDB
e. External Interfaces (grey):
• Browser APIs: WebCodecs, Canvas or WebGL, File System Access API, WebRTC
• 3rd-party libs: mp4box.js, @benev/slate
Relationships and data flow
• UI Component emits Action → Action Dispatcher → Updates Store → Notifies Controllers
• Controllers perform side effects:
• Compositor reads state, runs in Worker, renders frames via Canvas/WebCodecs → back to UI for preview
• Video-Export reads timeline/effects state → uses decode_worker & encode_worker → accumulates binary → writes file via OPFS
• Collaboration listens to state changes → serializes diffs → sends via WebRTC DataChannel → remote peers update their store
• State updates propagate back to UI Components → DOM re-render
Architectural patterns & design principles
• Unidirectional data flow (Flux-like)
• Layered separation: UI / State / Controllers / Workers / External
• Component-based UI via Web Components (custom elements)
• Encapsulation of side-effects in Controllers and Workers
• Use of browser-native high-performance APIs (WebCodecs, WASM)