Responsive web design has really taken off over the past few years, and especially in eCommerce....
[Case Study] How to Convert Videos with Elastic Transcoder
We were recently given the task of automatically converting user-uploaded videos to multiple formats for viewing on various devices, including on smartphones running versions of Android as low as 2.3.
Our starting point was a mobile application that allows users to upload files to the web – specifically, to upload files to a particular Amazon S3 Bucket. Therefore, all of the videos we wanted to convert were a) already in the cloud and b) already in one Bucket.
Though the file size of these videos was not large, their sheer number made us question what would be the fastest and most reliable method of converting them.
Today, we will share our experience.
Amazon Web Services
As mentioned, the collection of videos we were working with were stored in the Amazon Web Service’s S3 Cloud. Because of this, we decided to use Amazon’s cloud technology to power our conversions. Amazon S3 “provides developers and IT teams with secure, durable, highly-scalable object storage.” They also offer computing services, and one of their Web Services – Amazon Elastic Transcoder – met our needs perfectly.
Amazon Elastic Transcoder is media transcoding in the cloud. It is designed to be a highly scalable, easy-to-use, and cost-effective way for developers and businesses to convert (or “transcode”) media files from their source format into formats that will play on smartphones, tablets, and PCs.
The First Challenge: Convert Video Files Online
First, we set up the video conversion process. In the Pipelines section, we specified the Bucket for source files, the Bucket for output files (the destination), and the Bucket for video thumbnails.
The Presets tab provides us with a whole list of standard conversion options, courtesy of Amazon.
But we needed our own custom settings. We specified 6 out of 20 possible parameters: Bit Rate, Max Width, Max Height, Profile, Level, and Audio Bit Rate.
So far, we had set up our Pipeline and customized our Presets.
But the actual process of conversion is accomplished by Jobs. For each individual video file we must create a new Job, then choose the Pipeline for the Job, select a Preset, and run the conversion.
Now the magic happens – without needing any hardware or software in-house, Amazon’s Elastic Transcoder converts videos into the required format and puts them in the destination Bucket. Voila! A quick and reliable solution, even when many videos are being uploaded simultaneously. May the clouds be blessed! :)
The Second Challenge: Convert a Large Set of Existing Videos
Automatically converting newly-uploaded videos is great, but that was not our only objective. We already had a collection of around 150,000 videos sitting in the cloud. The task at hand was to choose videos larger than 6 MB and to reduce their size.
This problem is somewhat outside-the-box, given the limited number of operations that can be performed on files in the Amazon Bucket. In short, we had to manually sort and filter our files. We collected file metadata through the AWS SDK for Java and identified the files that we wanted to convert (those larger than 6 MB).
There appeared to be 35,000 video files larger than 6 MB, taking up around 200 GB of space.
Following the same process as previously, we created a Pipeline (specifying source and destination Buckets) and configured a Preset. Then we wrote a script that created a new Job for each video that needed to be converted:
// Setup the job input using the provided input key.
JobInput input = new JobInput().withKey(inputVideoUrl);
List<CreateJobOutput> outputs = new ArrayList<CreateJobOutput>();
//Create job output
outputs.add( new CreateJobOutput().withKey(outputVideoUrl).withPresetId(PRESET_ID));
// Create a job on the specified pipeline and return the job ID.
CreateJobRequest createJobRequest = new CreateJobRequest()
After 12 hours of conversion, the average file size of our videos had been cut in half or better. This resulted in significantly faster download times for users who were accessing these video files.
Nowadays, it is strictly not necessary to have high-performance computing capacity in-house. With online services such as Amazon Web Services, you can easily put your heavy work upon the shoulders of third parties. Doing so frees up your time, is more reliable, and costs much less than maintaining and updating your own high-end hardware and software.
Did you find this case study useful or interesting? Share it using the buttons below!
If you have any questions about online video conversion or how Web Services can power your website’s functionality, then drop us a line!