Build your own video encoder with AWS Batch, EC2, Docker and ffmpeg: Part-1

- Part-1: Code and pre-requisites
- Part-2: Setting up AWS batch and main executor script.
- Part-3[Optional]: Setting up DASH and HLS delivery-completely open-source.

Video encoding(transcoding) is the process of converting video data from one format to other usually to make it ingestible by different target devices.
Video transrating(re-encoding) is a type of video encoding where the bit-rate(number of bits required to store 1 second of video data) of a video is decreased to reduce the size of video file, this is quite useful for streaming or on-demand video delivery when the target device may have slower internet(or smaller screen size). The process also involves lowering down the frame rate(number of frames per second) to reduce the overall file size(ever notice frame drops on your favourite video-calling software when working with a low-bandwidth internet connection?).
There are a flurry of services available for storing managing and transcoding your video. These services are more costly than they should be and here we will learn how to develop an end-to-end on-demand video encoder with Amazon Web Services, docker and ffmpeg. We will implement our encoder using all open-source tools and libraries.
When deploying our transcoder on AWS, we would need some intensive compute through EC2 instances. EC2 instances can be simply launched and you can use ffmpeg library to transcode videos, but what about the time when you won’t be running these jobs, well you could simply stop the EC2 instances but you will still be charged for the hard-drive abd its a time consuming process and then your transcoder won’t be on-demand — enter docker and AWS Batch.
AWS Batch is a service to run batch workloads which are compute intensive like video-transcoding or ML model training. The only requirement is to have a docker image of the application you want to run and the data that is to be processed should be accessible the AWS Batch instances(usually in a S3 bucket). Batch pulls the docker image and creates containers on EC2 instances, whose type is configured and runs the jobs, that’s it.
Let’s start by creating our Dockerfile. We will assume that the code for the app is inside app folder.







