Skip to content
GitHub Discord

FFmpeg in Lambda

Uses FFmpeg to process videos. In this example, it takes a clip.mp4 and grabs a single frame from it.

We use the ffmpeg-static package that contains pre-built binaries for all architectures.

index.ts
import ffmpeg from "ffmpeg-static";

We can use this to spawn a child process and run FFmpeg.

index.ts
spawnSync(ffmpeg, ffmpegParams, { stdio: "pipe" });

We don’t need a layer when we deploy this because SST will use the right binary for the target Lambda architecture; including arm64.

sst.config.ts
{
nodejs: { install: ["ffmpeg-static"] }
}

All this is handled by nodejs.install.

sst.config.ts
const func = new sst.aws.Function("MyFunction", {
url: true,
memory: "2 GB",
timeout: "15 minutes",
handler: "index.handler",
copyFiles: [{ from: "clip.mp4" }],
nodejs: { install: ["ffmpeg-static"] },
});

View the full example.