AWS Elemental for Audio File Manipulation

Aug 28, 2021

An example of use of audio file manipulation using AWS Elemental

During the never-ending 2020, I joined a friend of mine in a project about audio streaming; that was a brand new topic for me, so after a few days of research and a suggestion from a friend, I have found MediaConvert, which is a component of AWS Elemental, a product that Amazon acquired not long time ago: it has all the tools needed to stream audio and video contents, both on-demand and live, and it also gives you the option to do real-time audio/video advertising.

Here are my 2 cents.

The solution

AWS Elemental is a full suite to handle audio and video on demand or live contents publication, fully integrated with the AWS ecosystem. It’s made of several components, like:

MediaConvert is the component that can load an asset from S3 and convert it, accordingly to your needs. You can, among other things:

and much more.

In order to manipulate an asset, you have to define a job; it is divided in sections, and some of them are:

A very important one is the Output groups, on the left bar of the “Job definition” page: it is the place to define what kind of asset you are creating:

Output group

Adding output group to a jogAs you can see, there are a bunch of options and in my case, Apple HLS was the one to choose to have a proper asset for streaming: it creates the .m3u8 file, which describes the stream, and a bunch of .aac files, which represent the parts of the assets that will be served during the streaming session.

As a word of advice, since I am not an expert on the streaming universe, I have used VLC to quickly verify that the produced output was correctly created: the final client application is developed using Flutter, and the player component has no particularly rich API, so VLC helped me a lot during the tests. So, would you ever want to play with MediaConvert, remember this: load your asset, convert and move it in an S3 bucket, make it publicly accessible, and try playing the resulting stream with VLC. Long story short: if VLC can play it, the player will, too.

Let’s put everything in context

From an architectural point of view, the application is based on Google Cloud Platform, and I only used AWS Elemental on purpose. There is a tool to upload the assets to S3; a lambda function detects the upload and starts a predefined MediaConvert job, and this will produce a coherent deliverable file into the target S3 bucket.

At this stage, a second lambda function detects the file creation in the target bucket and notifies that to a GCP cloud function, which creates an entry in Cloud Firestore, the database used by the Flutter application. Last but not least, I am using the Firebase authentication mechanism to handle my application users.

Conclusion

Every time you have the chance to start a new (side ?) project the interesting part is always what technology stack you are going to use: as a developer you know that a wrong decision can impact the whole project, causing delays and lack of motivation; on the other side, when you pick the right tools for the job, reduce the project bootstrap time for the project and focus on the business logic you end up being quite happy. At the end of the day, other than some Flutter development (playing with providers, bloc pattern, etc) and a couple of lambda functions, having AWS Elemental in the toolbox made the project “doable”.

Note: just to highlight how much is important to save on time and how this can be nicely done with the right tools, I can confirm that the longest task so far has been the logo design. With a third party designer :D

Additional notes

You can see one of the first presentations of AWS Elemental at re:Invent 2017 here.