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.
import ffmpeg from "ffmpeg-static";We can use this to spawn a child process and run FFmpeg.
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.
{ nodejs: { install: ["ffmpeg-static"] }}All this is handled by nodejs.install.
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.