OfflineSmelter
import { OfflineSmelter } from "@swmansion/smelter-node"OfflineSmelter is intended for offline processing e.g. if you need to combine few mp4 files together.
It has simplified API compared to the Smelter class, optimized for rendering just one output file as a result.
new Smelter()
Creates a new offline smelter instance. You have to call init() first before this object can be used.
new OfflineSmelter(manager?: SmelterManager)Type definitions
type ApiRequest = { method: 'GET' | 'POST'; route: string; body?: object;};
type MultipartRequest = { method: 'POST'; route: string; body: any;};
type SmelterManager = { setupInstance(): Promise<void>; sendRequest(request: ApiRequest): Promise<object>; sendMultipartRequest(request: MultipartRequest): Promise<object>; registerEventListener(cb: (event: unknown) => void): void;}Parameters
manager
Configures how the client code will connect and manage a Smelter server. Smelter SDK provides 2 implementations that you can use or extend:
LocallySpawnedInstnaceManager(Default Configuration) - Automatically download the necessary Smelter binaries and launch the server on your local machine.ExistingInstanceManager- Connect to a smelter server instance that is already running.
- Type:
SmelterManager
init()
Smelter.init(): Promise<void>Initialize the Smelter instance. This might spawn a new instance or just establish a connection, depending on the manager used while creating Smelter instance.
After init() you can start connecting inputs/outputs or register other elements. However, no output stream will be produced until start() method is called.
render()
import React from "react";
Smelter.render( root: React.ReactElement, output: RegisterOutput, durationMs?: number,): Promise<object>Type definitions
import { RegisterRtpOutput, RegisterMp4Output, RegisterWhipOutput} from "@swmasnion/smelter"
type RegisterOutput = | ({ type: 'rtp_stream' } & RegisterRtpOutput) | ({ type: 'mp4' } & RegisterMp4Output) | ({ type: 'whip' } & RegisterWhipOutput);Register external destination that can be used as a smelter output.
root- React component that controls composition layout on output.output- Protocol and encoder options for the output. Visit output documentation to learn more:durationMs- Duration of the generated output in milliseconds. If not provided it will be calculated based on duration of the content (based on lifetime of components like<SlideShow>,<Show>, or<Mp4>).
registerInput()
import { Inputs } from "@swmasnion/smelter"
Smelter.registerInput( inputId: string, input: Inputs.RegisterInput,): Promise<object>Type definitions
import { RegisterRtpInput, RegisterMp4Input, RegisterWhipInput} from "@swmasnion/smelter"
type RegisterInput = | ({ type: "rtp_stream" } & RegisterRtpInput) | ({ type: "mp4" } & RegisterMp4Input) | ({ type: "whip" } & RegisterWhipInput);Register external source that can be used as a smelter input. Visit input documentation to learn more:
registerImage()
import { Renderers } from "@swmansion/smelter"
Smelter.registerImage( imageId: string, image: Renderers.RegisterImage,): Promise<void>Register an image asset. See RegisterImage to learn more.
registerShader()
import { Renderers } from "@swmnasion/smelter"
Smelter.registerShader( shaderId: string, shader: Renderers.RegisterShader,): Promise<void>Register a shader. See RegisterShader to learn more.
registerFont()
Smelter.registerFont(source: string | ArrayBuffer): Promise<void>Register new font.