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.
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:
- MediaLive, to stream the contents
- MediaPackage, to prepare a different version of the contents to target multiple platforms
- MediaStore, to optimize assets storage
- MediaConvert, to convert assets on the fly
- MediaConnect, transport service for live video
- MediaTailor, for target-based advertising injection in your streams
MediaConvert is the component that can load an asset from S3 and convert it, accordingly to your needs. You can, among other things:
- convert to another format
- modify the properties (like KB/s)
- generate a streamable version of the content
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:
- input: the asset you want to manipulate
- video selector/audio selectors: lots of properties you can customise about the video or audio track, like language code
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:
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.
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
You can see one of the first presentations of AWS Elemental at re:Invent 2017 here.