How zhaohappy/libmedia works
Project type and purpose
• This is a TypeScript‑based multimedia library monorepo (“libmedia”) that provides modular components for audio/video I/O, demuxing/muxing, decoding/encoding, filtering, resampling, scaling, rendering, pipelines, player (AVPlayer) and transcoder (AVTranscoder).
• It ships both TS modules (e.g., avformat, avutil, avrender) and a set of WebAssembly (WASM) modules compiled from FFmpeg and other C/C++ codecs. It also includes a documentation/demo site and sample applications (player.html, transcoder.html).
File structure
• src/… → separate TS packages: avformat, avcodec, avutil, avnetwork, avprotocol, avfilter, avpipeline, avrender, avplayer, avtranscoder, audioresample, audiostretchpitch, videoscale, etc.
• dist/decode & dist/encode → compiled WASM codec modules, grouped by codec and feature set (baseline, atomic, simd, 64).
• site/ → Dumi-based documentation site with demos and guides.
• product/player → static demo player assets.
• examples/ → code snippets using the library.
• scripts/ & build/ → build, packaging, publishing, CI scripts.
• package.json & tsconfig.json at root manage the monorepo.
README for additional insights
• The README describes architecture: TS modules handle stream parsing, pipeline orchestration & WASM I/O interactions; WASM modules handle heavy compute (decode/encode).
• Supports optional multi‑threading via SharedArrayBuffer + Web Workers.
• Two sample applications: AVPlayer (playback via soft/hard decode + MSE) and AVTranscoder (transcode pipeline).
Elements
• Clear labels (e.g., “avformat”, “VideoDecoder.wasm”)
• Blue rectangles for TS modules
• Green rectangles for WASM modules
• Yellow parallelograms for browser APIs / threads
Detail and essential elements
• Major package is represented
• Multi‑threading: which components run in Workers vs main thread
• Integration points: how TS modules call into WASM, how SharedArrayBuffer is used