AWS Lambda + ReelSDK $0.02 per compute minute, first $0.50 free

Run ffmpeg from AWS Lambda without a layer or a 250 MB bundle

ReelSDK runs your ffmpeg 8.1 arguments on its own machines for $0.02 per compute minute, so the handler is one fetch and never meets Lambda's 250 MB package limit or its 900 s timeout. A 20-second 1080p clip comes back as a 720p mp4 and a poster frame in about 6 seconds.

  • One fetch on nodejs22.x or nodejs24.x, nothing to package
  • S3 inputs through presigned URLs, up to 500 MB each
  • Async jobs and a signed webhook, clear of the API Gateway timeout
What Lambda says when ffmpeg goes in the package

Unzipped size must be smaller than 262144000 bytes

Function code combined with layers exceeds the maximum allowed size of 262144000 bytes

Source: AWS re:Post, Lambda deployment package size

The same job as one call to ReelSDK

export const handler = async () => {
  const res = await fetch("https://api.reelsdk.com/v1/ffmpeg?wait=280", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.REELSDK_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      inputs: { "in.mp4": "https://api.reelsdk.com/f/lib/in/seo-int/nasa-vision.mp4" },
      args: [
        "-i", "in.mp4", "-map", "0:v", "-map", "0:a", "-vf", "scale=-2:720",
        "-c:v", "libx264", "-preset", "veryfast", "-crf", "23",
        "-c:a", "aac", "-b:a", "128k", "-movflags", "+faststart", "video-720p.mp4",
        "-map", "0:v", "-ss", "3", "-frames:v", "1", "-vf", "scale=-2:720", "-update", "1", "poster.jpg",
      ],
      outputs: ["video-720p.mp4", "poster.jpg"],
    }),
  });

  const { job, error } = await res.json();
  if (!res.ok) return { statusCode: res.status, body: JSON.stringify({ error }) };
  return { statusCode: res.status, body: JSON.stringify({ id: job.id, status: job.status, outputs: job.outputs }) };
};
200 with video-720p.mp4 and poster.jpg, about 6 seconds for a 20-second clip; a 202 and the job id when a render outlasts the 280 s waitTry it

Why ffmpeg breaks here

250 MB to ship, 900 s to run, 30 s behind API Gateway

Lambda accepts a 50 MB zip upload and allows 250 MB unzipped for the function and all its layers together. Add a static ffmpeg build to your dependencies and the deploy stops at Unzipped size must be smaller than 262144000 bytes; the way around it is a container image of up to 10 GB. The encode then needs memory and disk: 128 to 10,240 MB of memory, with the equivalent of one vCPU at 1,769 MB, and 512 to 10,240 MB of /tmp.

The timeout defaults to 3 s and stops at 900 s. A synchronous invoke carries 6 MB in each direction, and an API Gateway HTTP API ends the integration after 30 s, a quota you can't raise. A handler that holds ?wait=280 works when nothing with a shorter timeout sits in front of it, and Lambda bills it for the wait. For uploads, trigger on S3, start the job with Prefer: respond-async and let a second function take the webhook. Raw ffmpeg on ReelSDK costs $0.02 per compute minute, billed by the second, and failed jobs are free.

AWS Lambda next to ReelSDK

AWS Lambda next to ReelSDK
LimitAWS LambdaReelSDK
Package size50 MB zip, 250 MB unzipped with layers, 10 GB as an imageNothing to package, ffmpeg 8.1 is on the render machine
Run time3 s by default, 900 s at mostUp to 10 min per job; a request can wait up to 300 s
Payload6 MB request and 6 MB response per synchronous invokeInputs by URL, up to 500 MB each and 1 GB per job
Memory and disk128 to 10,240 MB of memory, 512 to 10,240 MB of /tmpA separate machine for every job
Behind API Gateway30 s integration timeout on HTTP APIsPrefer: respond-async answers 202 at once

AWS Lambda limits from Lambda quotas, checked November 2026.

Set it up

An S3 trigger, an async job and a webhook function

You need a ReelSDK key and its webhook secret. The fix above is the short version, a handler that waits for the render. For uploads, one function starts a job when a file lands in S3, and a second one behind a function URL receives the finished job and copies the outputs back to your bucket.

  1. Pick the runtime and set the variables

    Use nodejs22.x or nodejs24.x, which have fetch built in. Set REELSDK_KEY on the starter function, and REELSDK_WEBHOOK_SECRET and OUTPUT_BUCKET on the webhook function. The waiting handler fits easily in the 128 MB minimum. The two S3 functions load the AWS SDK, and the webhook one peaked at about 113 MB with a 2 MB video in memory, so give them more than 128 MB. The waiting handler needs a timeout above 280 s instead of the 3 s default.

  2. Start the job when a file lands in S3

    Point an S3 ObjectCreated notification at the starter. It presigns a GET URL for the new object, valid for 1 h, so ReelSDK can read the file while the bucket stays private, and calls POST /v1/ffmpeg with Prefer: respond-async. ReelSDK answers 202 with the job id and the function returns. The upload's S3 request id is the Idempotency-Key, so a repeated event or a Lambda retry doesn't start a second job. webhook_url is the webhook function's URL with the object key in the query string.

    starter/index.tsTry it
    import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
    import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
    import type { S3Event } from "aws-lambda";
    
    const s3 = new S3Client({});
    
    export const handler = async (event: S3Event) => {
      for (const record of event.Records) {
        const bucket = record.s3.bucket.name;
        const key = decodeURIComponent(record.s3.object.key.replace(/\+/g, " "));
    
        // ReelSDK reads the upload through a presigned URL, so the bucket stays private
        const source = await getSignedUrl(s3, new GetObjectCommand({ Bucket: bucket, Key: key }), { expiresIn: 3600 });
    
        const res = await fetch("https://api.reelsdk.com/v1/ffmpeg", {
          method: "POST",
          headers: {
            Authorization: `Bearer ${process.env.REELSDK_KEY}`,
            "Content-Type": "application/json",
            Prefer: "respond-async",
            "Idempotency-Key": `s3-${record.responseElements["x-amz-request-id"]}`,
          },
          body: JSON.stringify({
            inputs: { "in.mp4": source },
            args: [
              "-i", "in.mp4", "-map", "0:v", "-map", "0:a", "-vf", "scale=-2:720",
              "-c:v", "libx264", "-preset", "veryfast", "-crf", "23",
              "-c:a", "aac", "-b:a", "128k", "-movflags", "+faststart", "video-720p.mp4",
              "-map", "0:v", "-ss", "3", "-frames:v", "1", "-vf", "scale=-2:720", "-update", "1", "poster.jpg",
            ],
            outputs: ["video-720p.mp4", "poster.jpg"],
            webhook_url: `${process.env.WEBHOOK_URL}?key=${encodeURIComponent(key)}`,
          }),
        });
    
        // 409: an earlier delivery of this event already started the job
        if (res.status === 409) continue;
        if (!res.ok) throw new Error(`reelsdk ${res.status}: ${await res.text()}`);
        const { job } = await res.json();
        console.log("reelsdk job started", job.id, key);
      }
    };
    
  3. Verify the webhook and copy the outputs

    Give the second function a function URL with auth type NONE; the signature check is the authentication. Decode the body when isBase64Encoded is set, check Reelsdk-Signature and reject timestamps more than 300 s old. Each output is a URL, and the handler copies it to renders/<key>/ in your bucket. A delivery gets 15 s before ReelSDK retries it, up to 6 attempts over about 7 h, and a retry overwrites the same keys. Our run produced video-720p.mp4 and poster.jpg.

    webhook/index.ts
    import { createHmac, timingSafeEqual } from "node:crypto";
    import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
    import type { LambdaFunctionURLEvent } from "aws-lambda";
    
    const s3 = new S3Client({});
    
    export const handler = async (event: LambdaFunctionURLEvent) => {
      const body = event.isBase64Encoded ? Buffer.from(event.body ?? "", "base64").toString("utf8") : (event.body ?? "");
      if (!verifyReelsdkSignature(event.headers["reelsdk-signature"] ?? "", body, process.env.REELSDK_WEBHOOK_SECRET!)) {
        return { statusCode: 401, body: "invalid signature" };
      }
    
      const job = JSON.parse(body);
      if (job.status !== "succeeded") {
        console.error("reelsdk job failed", job.id, job.error);
        return { statusCode: 200, body: "ok" };
      }
    
      // Each output is a URL; we copy it into the bucket under renders/
      const key = event.queryStringParameters?.key ?? job.id;
      for (const [name, url] of Object.entries<string>(job.outputs)) {
        const file = await fetch(url);
        await s3.send(
          new PutObjectCommand({
            Bucket: process.env.OUTPUT_BUCKET,
            Key: `renders/${key}/${name}`,
            Body: Buffer.from(await file.arrayBuffer()),
            ContentType: file.headers.get("content-type") ?? undefined,
          }),
        );
      }
      return { statusCode: 200, body: "ok" };
    };
    
    function verifyReelsdkSignature(header: string, body: string, secret: string) {
      const parts = Object.fromEntries(header.split(",").map((part) => part.split("=", 2)));
      const age = Math.abs(Date.now() / 1000 - Number(parts.t));
      if (!/^[0-9a-f]{64}$/i.test(parts.v1 ?? "") || !(age <= 300)) return false;
    
      const expected = createHmac("sha256", secret).update(`${parts.t}.${body}`).digest();
      return timingSafeEqual(expected, Buffer.from(parts.v1, "hex"));
    }
    

FAQ

Video on AWS Lambda, answered

Can AWS Lambda run ffmpeg without a layer?

Yes, when the encode runs somewhere else. The handler sends your ffmpeg arguments and input URLs to POST /v1/ffmpeg with the fetch built into nodejs22.x and nodejs24.x, and ReelSDK runs them with ffmpeg 8.1 on its own machines. The deployment package stays a few kilobytes of JavaScript, with no layer, no static binary and no container image.

Why does my Lambda deploy fail with Unzipped size must be smaller than 262144000 bytes?

262144000 bytes is 250 MB, the unzipped limit for a function and all its layers together. A static ffmpeg build plus your dependencies can pass it. Either move to a container image of up to 10 GB, or keep ffmpeg out of the function and call it over HTTPS.

How do I get past the 30 s API Gateway timeout with video jobs?

An API Gateway HTTP API ends the integration after 30 s, whatever the function's own timeout is. Send Prefer: respond-async and ReelSDK answers 202 with the job id right away. The finished job then arrives at your webhook_url, or you poll GET /v1/jobs/{id}.

How do I pass a large S3 file to the render?

Not through the function: a synchronous invoke carries 6 MB and /tmp starts at 512 MB. Presign a GET URL for the object and put it in inputs. ReelSDK reads inputs of up to 500 MB each and 1 GB per job straight from S3, and the bucket stays private.

What does it cost next to running ffmpeg in Lambda?

Raw ffmpeg on ReelSDK is $0.02 per compute minute, billed by the second, and failed jobs are free. Lambda on x86 bills $0.0000166667 per GB-second and $0.20 per million requests after a free 1 million requests and 400,000 GB-seconds a month. With the async pattern your functions run for their HTTP calls and the copy, not for the encode.

All integrations

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains