Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Node.js (TypeScript)

Server-side video processing and CLI tools call Mediaway through a native addon / N-API (koffi FFI today) over the mediaway-ffi C ABI. Status: ✅ verified.

Install

npm install @mediaway/container   # also @mediaway/device, @mediaway/encoder, @mediaway/ffi
import { Muxer } from "@mediaway/container";

const muxer = new Muxer();
const videoTrack = muxer.addVideoTrack({
  codec: "h264", width: 1920, height: 1080,
  pixelFormat: "nv12", timeBase: { num: 1, den: 30 },
});
const chunks: Buffer[] = [muxer.begin()]; // init segment (ftyp + moov), write once

muxer.push({
  trackIndex: videoTrack,
  data: Buffer.from([0, 0, 0, 1]),
  pts: 0, duration: 1, key: true,
});
muxer.flush();
for (let chunk = muxer.pollBytes(); chunk.length > 0; chunk = muxer.pollBytes()) {
  chunks.push(chunk);
}

Examples live in bindings/nodejs/examples/:

CapabilityExample files
Containercontainer/mux-roundtrip.ts
Devicedevice/camera-record.ts · capture-microphone.ts · capture-screen.ts
Pipelinepipeline/encode-audio.ts · encode-to-mp4.ts · screen-record.ts

Build and run instructions: bindings/nodejs/README.md.