Building plugins for the Eyevinn Ingest Application Framework
Tags: video, transcoding, aws
Published: 2021-09-23 13:36:24

## Introduction 
As introduced by my colleague Fredrik the [Eyevinn Ingest Application Framework](https://dev.to/video/the-eyevinn-ingest-application-framework-making-ingest-flows-modular-pjj) (IAF) allows you to build plugins in a modular way that can interact with different storage or transcoding solutions. 
In this short walkthrough we will show you how you can use two of the IAF plugins that we have developed to easily transcode and make on demand video content (VOD) available on multiple devices using [AWS Elemental MediaConvert](https://aws.amazon.com/mediaconvert/) and [AWS Elemental MediaPackage](https://aws.amazon.com/mediapackage/).  

Lets for example say that we have a couple of local video files in MP4 format that we want our users to be able to stream on a wide range of devices. How would we in an easy way make the publicly available? One way is to use AWS MediaConvert to first transcode the files into Apple HLS and then utilise AWS MediaPackage to re-package it to two endpoint types; DASH-ISO and Apple HLS. We can then use a CDN for example CloudFront to deliver the video to the output devices.

## The plugins 
![diagram of example IAF service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ndv90gdwcdkxjodnsifa.png)

To automate this process as much as possible the [IAF AWS transcoding plugin](https://github.com/Eyevinn/iaf-plugin-aws) and the newly added [IAF MediaPackage plugin](https://github.com/Eyevinn/iaf-plugin-aws-mediapackage) can be used to push transcoded content to MediaPackage.

Both plugins main modules are the `AwsUploadModule` that implements the `IafUploadModule` interface. This module interacts with the S3 storage, MediaConvert and MediaPackage. Our IAF applications only needs the `onFileAdd` method to start uploading the file and start the transcoding. When instantiating the `AwsUploadModule` it's possible to provide a custom encoder profile. An example when this would be useful could be when we have a video file with only on audio track in 5.1 but we want the output to have two, one in stereo and one in surround.  When the file have been uploaded a _watcher_ starts monitoring the output bucket for the transcoded master manifest(s).

When the transcoding plugin have finished uploading the content and a transcoding job have been successfully completed the _watcher_ will pass the AWS source ARN:s as an object to the `fileUploadedDelegate`. This callback function can be injected when we instantiate `AwsUploadModule` this is what makes the framework really great and modular because now we can chain two IAF plugins together.

The IAF MediaPackage plugin's `onFileAdd` method expect the ARN of the transcoded HLS master manifest in this case (it's possible to transcode into multiple formats depending on the configuration JSON) and will start call the dispatcher to create a re-packaging job in MediaPackage. Currently you need to have created a packaging group via the AWS console and provide the `packagingGroupId` this is something what we would like to update so that we can create the packaging group "on the fly" and pass that to the plugin. The `fileUploadedDelegate` in this plugin will if the dispatcher have succeeded get the result from MediaPackage including the endpoints.

Example of the iaf-aws and iaf-aws-mediapackage plugins: 

{% gist https://gist.github.com/oscnord/c2a50ad1ae6b53eef9b834c2dbbb6cda %}

The possibility to chain plugins together and/or add other services on top of this gives us the advantage that we can for example instead of transcoding VOD content with MediaPackage add another IAF plugin for MediaLive or some other on-premise live encoder and push that into our MediaPackage plugin without modifying the underlying structure of the framework.

## Conclusion

As mentioned in the [Eyevinn Ingest Application Framework](https://dev.to/video/the-eyevinn-ingest-application-framework-making-ingest-flows-modular-pjj) article by Fredrik the IAF is still a work in progress and we encourage readers to keep an eye on the website for changes and news. We hope that the IAF will be able to help developers build their own ingest applications faster, and remove some of the complexity from the process.  

If you need assistance in the development and implementation of this, our team of video developers are happy to help you out. If you have any questions or comments just drop a line in the comments section to this post.