Introduction
In today’s digital landscape, media processing is no longer just a backend concern - it is a core part of user experience.
Users expect instant uploads, fast playback, and consistent quality across devices and network conditions.
At the same time, platforms must manage storage growth and CDN costs at scale.
This case study explores a production-ready, event-driven media processing pipeline on AWS.
By adopting a serverless-first architecture, raw uploads are automatically converted into
adaptive HLS video streams and highly optimized WebP images, all without manual infrastructure management.
The Challenge

Modern media platforms face a difficult balance between performance, scalability, and cost.
High-resolution content improves visual quality but introduces buffering, storage overhead, and increased bandwidth usage.
Key Requirements
Video Versatility: Support MP4, MOV, and MKV formats ranging from 10MB to several gigabytes
Adaptive Streaming: Deliver HLS streams at 1080p, 720p, and 360p
Aggressive Image Optimization: Achieve 95%+ file size reduction with minimal quality loss
Operational Efficiency: Eliminate server management and pay only for actual processing time
Architectural Philosophy
The system is built on an event-driven architecture where Amazon S3 upload events automatically
trigger processing workflows. This removes the need for polling or manual intervention and ensures
compute resources are consumed only when content is uploaded.

Key principles include:
Serverless-first design using AWS-managed services
Loose coupling between upload, processing, and delivery
Automatic scaling from zero to peak traffic without capacity planning
Intelligent Upload Strategy
To optimize the first mile of content delivery, the platform uses a dual upload strategy
based on a 25MB file size threshold.
Upload Modes
Direct Upload (< 25MB)
S3 presigned URLs with transfer acceleration
Single HTTP PUT request
A 20MB file uploads in seconds
Multipart Upload (≥ 25MB)
Files split into 5–10MB chunks
Parallel uploads with per-part retries
Reduces a 100MB upload from ~3 minutes to under 30 seconds
Video Processing Pipeline (HLS & ECS Fargate)
Workflow Overview
A video is uploaded to the source S3 bucket
An S3 event triggers a Video Processing Lambda
The Lambda orchestrates an ECS Fargate task
FFmpeg performs multi-bitrate video processing
Output is delivered globally via CloudFront
Why ECS Fargate?
Video processing can exceed Lambda’s 15-minute timeout
Provides unlimited runtime with dedicated 2 vCPUs and 4GB RAM
Automatically scales and charges only for task duration
HLS Conversion Process
The FFmpeg-based workflow performs:
Metadata extraction using FFprobe
Orientation-aware resolutions
Landscape: 1080p, 720p, 360p
Portrait: 1080×1920, 720×1280, 360×640
Thumbnail generation
High-quality JPEG
2-second animated GIF
Audio normalization
Adds silent audio when missing for browser compatibility
Multi-bitrate HLS encoding
H.264 codec
6-second segments per resolution
Master playlist creation
Enables adaptive quality switching
Processing Time:
A 20MB video completes in approximately 2 minutes, producing three adaptive quality levels plus thumbnails.
Image Processing Pipeline (Sharp & WebP)
Sharp Lambda Layer Architecture
Image uploads trigger a lightweight Lambda function powered by Sharp, a high-performance
image processing library built on libvips.
Packaged as a custom Lambda layer
Compiled for Amazon Linux (Lambda runtime)
Keeps deployment packages small and efficient
Optimization Workflow
Download original image from S3
Detect and convert HEIC/HEIF images if required
Convert to WebP (85% quality)
Extract metadata and compression statistics
Upload optimized image to destination bucket
Update database with retry and exponential backoff
Processing Time: Images complete in under 3 seconds.
Real-World Example
Original JPEG: 1.82 MB
Optimized WebP: 42 KB
97.7% size reduction with visually identical quality
Results & Impact
Scalability
1,000+ videos and 5,000+ images processed daily
Automatic scaling to 100+ concurrent ECS tasks
Zero infrastructure management
Performance
Video processing:
~2 minutes for 20MB files
4–5 minutes for 100MB files
Image processing: 2–3 seconds average
Playback: Instant start with adaptive quality switching
Cost Savings
95–98% image size reduction
90% CDN bandwidth savings
Faster page loads and improved SEO
Key Technical Lessons
Lambda vs ECS: Lambda for orchestration and lightweight tasks, ECS Fargate for long-running FFmpeg workloads
HLS over MP4: Adaptive streaming eliminates buffering on slow networks
WebP Adoption: Modern browser support makes WebP the ideal format
Lambda Layers: Native binaries deliver high performance without external services
Conclusion
This project demonstrates how serverless architectures can power complex, compute-intensive media workflows
with minimal operational overhead. By combining AWS Lambda, ECS Fargate, S3, and CloudFront,
the platform scales automatically, costs pennies per upload, and delivers a smooth, high-quality media experience.
The result is a future-proof media pipeline that balances performance, scalability, and cost efficiency -
without managing servers.