MP4
An input type that allows Smelter to read static MP4 files.
Usage
import Smelter from "@swmansion/smelter-node";
async function run() { const smelter = new Smelter(); await smelter.init(); await smelter.registerInput("example", { type: "mp4", serverPath: "./input.mp4" });}void run();Reference
Type definitions
type RegisterMp4Input = { type: "mp4"; url?: string; serverPath?: string; loop?: bool; required?: bool; offsetMs?: number; seekMs?: number; decoderMap?: DecoderMap; sideChannel?: SideChannel;}Parameters for registering an MP4 file as an input.
Properties
url
URL of the MP4 file.
- Type:
string - Option availability: Node.js , Browser (WASM)
serverPath
Path to the MP4 file, specifying its location on the server where the Smelter instance is deployed.
- Type:
string - Option availability: Node.js
loop
Specifies whether the input should be played in a loop.
- Type:
boolean - Default value:
false - Option availability: Node.js
required
Determines if the input stream is essential for output frame production. If set to true and the stream is delayed, Smelter will postpone output frames until the stream is received.
- Type:
boolean - Default value:
false - Option availability: Node.js
offsetMs
Offset in milliseconds relative to the pipeline start (start request). If unspecified, the stream synchronizes based on the delivery time of the initial frames.
- Type:
number - Option availability: Node.js
seekMs
Start playing from a specific timestamp in milliseconds. If loop is enabled, subsequent iterations start from the beginning. The input can also be seeked at runtime through the handle returned from registerInput.
- Type:
number - Option availability: Node.js
decoderMap
Assigns which decoder should be used for media encoded with a specific codec.
- Type:
DecoderMap
sideChannel
Enable side channel publishing for this input. The external
consumer reads decoded frames / audio from a Unix socket created under
SMELTER_SIDE_CHANNEL_SOCKET_DIR.
- Type:
SideChannel - Option availability: Node.js
DecoderMap
Maps codecs to the provided decoders.
Type definitions
type DecoderMap = { h264?: 'ffmpeg_h264' | 'vulkan_h264';};Properties
h264
H264 decoder configuration.
- Type:
'ffmpeg_h264' | 'vulkan_h264' - Default value: If available
vulkan_h264will be used, otherwiseffmpeg_h264 - Supported values:
"ffmpeg_h264"- Software H264 decoder based on FFmpeg."vulkan_h264"(Required feature: gpu-video ) - Hardware decoder. Requires GPU that supports Vulkan Video decoding.
SideChannel
Per-track side channel configuration. See the Side Channel overview for details on how decoded data is exposed and consumed.
Type definition
type SideChannel = { video?: boolean; audio?: boolean; delayMs?: number;};Properties
video
Publish decoded RGBA video frames for this input on the side channel.
- Type:
boolean - Default value:
false
audio
Publish decoded PCM audio batches for this input on the side channel.
- Type:
boolean - Default value:
false
delayMs
Side channel delay in milliseconds. Frames are buffered for this duration ahead of when the queue consumes them, so the side-channel subscriber receives them early and has roughly this much time to process before the frame is due.
- Type:
number - Default value:
0