This project demonstrates a video transcoding service using a combination of technologies including Terraform, TypeScript, Node.js, Redis, AWS, FFMPEG, and Docker. The service is designed to transcode videos into multiple resolutions (360p, 480p, 720p, 1080p) and upload them to a destination bucket.
- Terraform: Infrastructure as Code (IaC) tool used to provision and manage AWS resources.
- TypeScript
- Node.js
- Redis: An in-memory data structure store, used as a database, cache, and message broker.
- AWS: Amazon Web Services
- FFMPEG: A complete, cross-platform solution to record, convert, and stream audio and video.
- Docker
The project begins with a Lambda function that is attached to an AWS API Gateway. This function provides a presigned POST URL to upload videos to a source video bucket. Once a video file is uploaded to the S3 bucket, it triggers the Lambda function, which then initiates an ECS task using a transcoder Docker image.
The transcoder Docker image takes the key of the video from the source video bucket and the destination video bucket. It uses FFMPEG to transcode the video into different scales for multiple resolutions (360p, 480p, 720p, 1080p) and uploads the transcoded videos to the destination bucket.
To keep track of every key that is being processed, Redis is used to store key-value pairs of the video key and its current state (e.g., Processing, Complete, Failed).
- Scalability: The use of AWS and Docker ensures that the service can scale to handle large volumes of video transcoding requests.
- Efficiency: By using FFMPEG for video transcoding and Redis for state management, the service is efficient in processing and tracking video transcoding tasks.
- Reliability: The infrastructure is provisioned and managed using Terraform, ensuring that the service is reliable and consistent across deployments.
To get started with this project, you will need to:
-
Set up your AWS account and configure the necessary permissions for Terraform, Lambda, ECS, and S3.
-
Install Terraform, Node.js, Docker, and FFMPEG on your local machine.
-
Clone this repository and navigate to the project directory.
-
Run
terraform init
to initialize the Terraform configuration. -
Make the necessary
.tfvars
file. -
Run
terraform apply
to provision the AWS resources. -
Deploy the Lambda function and ECS task definition using the provided scripts.
-
Building and Pushing the Transcoder Docker Image to
Amazon ECR
- Navigate to the Amazon ECR page in your AWS Management Console.
- Obtain the push commands provided by ECR for your repository.
- Execute the push commands in your terminal to build the transcoder Docker image and push it to your ECR repository.
-
Test the service by uploading a video to the source S3 bucket and verifying that the transcoded videos are uploaded to the destination bucket.
Note: In some time, I will automate this process to streamline the deployment and setup of the transcoder Docker image.
Contributions are welcome! Please feel free to submit pull requests or open issues to improve the project.