Skip to content

Mp4

A component that renders content of Mp4 file. It is simpler alternative to the InputStream component that does not require registration, but with more limited set of options.

Reference

Mp4Example.tsx
import { Mp4, Rescaler } from "@swmansion/smelter";
import Smelter from "@swmansion/smelter-node";
function ExampleApp() {
return (
<Rescaler>
<Mp4 source="https://example.com/video.mp4" />
</Rescaler>
);
}
async function run() {
const smelter = new Smelter();
await smelter.init();
await smelter.registerOutput("output", <ExampleApp />, {
12 collapsed lines
type: "mp4",
serverPath: "./output.mp4",
video: {
encoder: {
type: "ffmpeg_h264",
preset: "ultrafast",
},
resolution: {
width: 1920,
height: 1080,
},
},
});
await smelter.start();
}
void run();
Type definitions

type Mp4Props = {
source: string;
volume?: number;
muted?: boolean;
}

Props

source

Url or local path to the mp4 file. Note that the path has to be local to the machine where Smelter server runs.

  • Type: string

volume

Audio volume of the input stream. Accepts values between 0 and 1.

  • Type: number
  • Default value: 1

muted

Determines whether to mute audio of the input stream.

  • Type: boolean
  • Default value: false