Skip to content

MP4

Node.js Browser (WASM)

An input type that allows Smelter to read static MP4 files.

Usage

mp4InputExample.tsx
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;
videoDecoder?: "ffmpeg_h264" | "vulkan_video";
}

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

videoDecoder

The decoder to use for decoding video.

  • Type: "ffmpeg_h264" | "vulkan_video"
  • Option availability: Node.js
  • Default value: ffmpeg_h264
  • Supported values:
    • "ffmpeg_h264" - Use the software decoder based on ffmpeg.

    • "vulkan_video" (Required feature:vk-video ) - Use hardware decoder based on Vulkan Video.

      This should be faster and more scalable than the ffmpeg decoder, if the hardware and OS support it.

      This requires hardware that supports Vulkan Video. Another requirement is this program has to be compiled with the vk-video feature enabled (enabled by default on platforms which support Vulkan, i.e. non-Apple operating systems and not the web).