DEV Community

Cover image for Building a Serverless Video Processing Pipeline with AWS Lambda, S3, and FFmpeg
nicolay Armando
nicolay Armando

Posted on

Building a Serverless Video Processing Pipeline with AWS Lambda, S3, and FFmpeg

Video is no longer “nice to have” — it’s becoming core infrastructure for modern digital products.

From onboarding flows to marketing assets and internal documentation, teams are producing more video than ever. But managing video processing at scale? That’s where systems often break.

In this guide, we’ll build a serverless video processing pipeline that automatically:

  • Ingests uploaded videos
  • Transcodes them into optimized formats
  • Generates thumbnails
  • Stores processed assets for delivery

All powered by:

  • AWS S3
  • AWS Lambda (FaaS)
  • FFmpeg
  • Event-driven architecture

No servers. No queues to manage. Fully scalable.

Why Serverless for Video Processing?

Traditional video pipelines rely on long-running servers or expensive managed platforms. Serverless changes the equation.

Benefits:

  • Scales automatically with demand
  • Pay only when processing happens
  • No infrastructure to maintain
  • Easy integration into product workflows

This architecture is increasingly being used beyond tech products. We now see similar pipelines supporting media workflows in public sector communication, education platforms, and industrial documentation. Some real-world examples across these sectors can be seen in projects for
councils and government teams,
education and higher learning institutions, and
manufacturing and engineering organizations.

The common thread: scalable, automated media handling.

Architecture Overview

Here’s the flow we’re building:

  1. User uploads video to S3 (raw-uploads bucket)
  2. S3 triggers AWS Lambda
  3. Lambda runs FFmpeg to:
  • Transcode to MP4 (H.264)
  • Generate thumbnail image
    1. Outputs saved to another S3 bucket (processed-videos)
Upload → S3 → Lambda → FFmpeg → S3 (outputs)
Enter fullscreen mode Exit fullscreen mode

Simple. Powerful. Scalable.


Step 1: Create S3 Buckets

Create two buckets:

  • myapp-raw-videos
  • myapp-processed-videos

You’ll configure the first bucket to trigger Lambda on upload.

Step 2: Create Lambda Function

Runtime:

  • Node.js 18.x or Python 3.10

Memory:

  • Minimum 1024MB (FFmpeg is resource-heavy)

Timeout:

  • 1–3 minutes depending on video size

We’ll use Node.js in this tutorial.

Step 3: Package FFmpeg for Lambda

Lambda doesn’t include FFmpeg by default. You’ll need a static build.

Options:

  • Use an FFmpeg Lambda Layer (recommended)
  • Or compile your own static binary

A commonly used community layer is available via the serverlesspub repository on GitHub. Attach the layer to your Lambda function and confirm that the binary is available at runtime.

Step 4: Lambda Function Code

Example index.js:

const AWS = require("aws-sdk");
const { exec } = require("child_process");
const fs = require("fs");
const path = require("path");

const s3 = new AWS.S3();

exports.handler = async (event) => {
  const bucket = event.Records[0].s3.bucket.name;
  const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " "));

  const inputPath = `/tmp/input.mp4`;
  const outputPath = `/tmp/output.mp4`;
  const thumbnailPath = `/tmp/thumb.jpg`;

  // Download from S3
  const data = await s3.getObject({ Bucket: bucket, Key: key }).promise();
  fs.writeFileSync(inputPath, data.Body);

  // Run FFmpeg
  await runCommand(`ffmpeg -i ${inputPath} -vf "scale=1280:-2" ${outputPath}`);
  await runCommand(`ffmpeg -i ${inputPath} -ss 00:00:01 -vframes 1 ${thumbnailPath}`);

  // Upload outputs
  await s3.putObject({
    Bucket: "myapp-processed-videos",
    Key: `videos/${path.basename(key)}`,
    Body: fs.readFileSync(outputPath),
    ContentType: "video/mp4"
  }).promise();

  await s3.putObject({
    Bucket: "myapp-processed-videos",
    Key: `thumbnails/${path.basename(key)}.jpg`,
    Body: fs.readFileSync(thumbnailPath),
    ContentType: "image/jpeg"
  }).promise();

  return { status: "success" };
};

function runCommand(cmd) {
  return new Promise((resolve, reject) => {
    exec(cmd, (error) => {
      if (error) reject(error);
      else resolve();
    });
  });
}
Enter fullscreen mode Exit fullscreen mode

Step 5: Configure S3 Event Trigger

On your myapp-raw-videos bucket:

  • Go to Properties → Event notifications
  • Trigger: All object create events
  • Destination: your Lambda function

Now every upload automatically processes.

Real-World Considerations

In production, you’ll want to add:

  • File type validation
  • Duration limits
  • Error handling + retries
  • CloudWatch logging
  • Presigned upload URLs
  • Queue buffering (SQS) for burst traffic
  • CDN delivery via CloudFront

This is the same architectural thinking behind many modern media workflows used by organisations building serious video ecosystems. You can see how structured media systems translate into real outcomes by exploring practical project examples across different industries.

structured media systems

Where This Architecture Is Already Showing Value

Serverless pipelines like this are increasingly supporting:

  • Public sector digital communication
  • Education platforms managing lecture content
  • Industrial teams managing training media
  • Marketing teams running multi-format campaigns

Many of these patterns are visible in the growing body of insights shared on the creative content and video strategy blog, where technical workflows increasingly intersect with real communication needs.

Going Further

You could extend this pipeline by adding:

  • Multiple resolutions (360p, 720p, 1080p)
  • WebVTT subtitle generation
  • AI transcription with AWS Transcribe
  • Auto-tagging with Rekognition
  • Metadata storage in DynamoDB
  • Completion events via EventBridge

At that point, you’re no longer just “processing video” — you’re building infrastructure for serious media systems.

Final Thoughts

Serverless video pipelines are quickly becoming the default for teams that care about:

  • Scalability
  • Cost control
  • Automation
  • Performance

Whether you're building a SaaS product, supporting a content team, or designing media workflows across an organization, this architecture gives you a strong, modern foundation.

If your interest leans more toward the strategic and operational side of video systems, you may find value in exploring how teams structure professional media workflows through services like video and media production systems or even how dedicated environments such as a creative production studio support high-quality output alongside technical infrastructure.

Top comments (0)