Skip to content

Overview

Package @swmansion/smelter-node allows you to control a Smelter server from the Node.js process.

When using this approach your React code runs inside Node.js process, and any updates to the React component tree are transmitted to the Smelter server as layout updates over HTTP requests. By default, the Smelter server is automatically launched on the same machine as Node.js, but you may choose to deploy it independently and simply provide the library with the connection URL.

You can use it in 2 modes:

  • Live processing

    This is the most flexible approach. It allows you to dynamically add and remove inputs/outputs at any point. By default, media is processed in real time, but this can be affected by e.g. required inputs or global settings.

    Check out Smelter documentation.

    Example

    import Smelter from "@swmansion/smelter-node"
    async function run() {
    const smelter = new Smelter();
    await smelter.init()
    // register inputs, outputs, or other resources e.g.
    await smelter.registerOutput("example", <View />, {
    type: "rtmp_client",
    url: "rtmp://example.com/app/stream_key",
    video: {
    encoder: { type: "ffmpeg_h264" },
    resolution: { width: 1920, height: 1080 },
    },
    audio: {
    channels: "stereo",
    encoder: { type: "aac" },
    }
    });
    await smelter.start()
    // you can register additional input/outputs at any point
    }
    void run();

  • Offline processing

    Mainly useful to take one or more static files and produce a single output. API in this mode is very limited: you need to define all inputs before start, there can be only one output.

    Check out OfflineSmelter documentation.

    Example

    import { OfflineSmelter } from "@swmansion/smelter-node"
    async function run() {
    const smelter = new OfflineSmelter();
    await smelter.init()
    // register inputs
    await smelter.render(<View />, {
    type: "mp4",
    serverPath: "./output.mp4",
    video: {
    encoder: { type: "ffmpeg_h264" },
    resolution: { width: 1920, height: 1080 },
    },
    audio: {
    channels: "stereo",
    encoder: { type: "aac" },
    }
    });
    }
    void run();

Smelter managers

@swmansion/smelter-node controls the Smelter server via SmelterManager interface. You can pass them as an argument when initializing Smelter or OfflineSmelter instance. The package provides 2 implementations:

Compatibility

@swmansion/smelter-node can be used with specific version of Smelter server and React.

SDK versionSmelter server versionReact version
v0.2.0
v0.2.1
v0.4.0
v0.4.1

Recommended: 18.3.1

Should work with any react version that is compatible with react-reconciler@0.29.2

v0.3.0v0.5.0

Recommended: 18.3.1

Should work with any react version that is compatible with react-reconciler@0.29.2

You need to remember about requirements of the actual Smelter server too. See Smelter server deployment options: