AWS for M&E Blog

Dynamically configuring job settings with AWS Elemental MediaConvert

Businesses in the media industry often have supply chain systems where their upstream vendors (such as content creators or production companies) receive and ingest large media files. These media files come in a variety of file formats, and the individual file sizes often reach hundreds of gigabytes in size.

After the media files are ingested by the upstream vendors, they typically undergo a quality assurance process. Once the files have passed this quality check, they are then packaged and distributed to the media company’s downstream customers.

During quality assurance, downloading such large files consumes lot of resources (memory, network, CPU) and time. Hence, an important step in their business process is to transcode and reduce the size of media files.

Transcoding is the process of converting an audio or video from one format to another. This enables customers to create digital assets in different formats and supports use cases including:

  1. Playing media on devices that are not supported before transcoding. For example, converting a Windows Media file to MP4 (MPEG-4 Part 14) for supporting wider compatibility.
  2. Compressing large media files to a smaller size without compromising the video quality, to make storing and sharing content more efficient.

Given the large volume of media files that needs features such as digital rights management, and transcoding, many media companies use AWS Elemental MediaConvert to handle these requirements.

What is AWS Elemental MediaConvert?

AWS Elemental MediaConvert (MediaConvert) is a file-based video processing service that transcodes content for broadcast and multi-screen delivery at scale. This service provides the following features:

  1. Scalability and Elasticity: Automatically scaling to handle transcoding workloads, provisioning the necessary compute resources as needed. This facilitates handling peak loads without compromising performance or turnaround time.
  2. Reliability: Running transcoding jobs on redundant infrastructure across multiple Availability Zones, providing high availability and fault tolerance.
  3. Ease of Use: An intuitive user interface, as well as comprehensive APIs, make it straightforward to integrate transcoding into existing workflows.
  4. Optimizing Cost: Pay-as-you-go pricing model and automatic scaling capabilities help you optimize transcoding costs, as you pay for the resources you use.

To transcode media files using AWS Elemental MediaConvert, jobs are configured and submitted with the required encoding settings. We will explore how the job settings in MediaConvert can be dynamically configured. Specifically, we will demonstrate the ability to programmatically configure audio tracks while transcoding the video files.

The video files that have been transcoded using the configured settings are then utilized for various purposes. For example, they can be used for playback on different media devices, and as part of the quality assurance process are integrated into other business workflows.

Another example of dynamically configurable job settings in MediaConvert includes parameters such as bitrate and name modifiers. With MediaConvert, it is possible to programmatically configure any of the available job settings.

Dynamically configure the audio tracks during video file transcoding

Let’s explore how the job settings in AWS Elemental MediaConvert can be dynamically configured. Specifically, we will demonstrate the ability to programmatically configure the audio tracks at the same time transcoding the video files.

The following architecture diagram is an overview of the process.

Architectural diagram that provides an overview of the user uploading the video files in the source S3 bucket. The Dynamic Media Service which is a Java service invokes the MediaConvert job to transcode the video files and then placed in the output S3 bucket for consumption. The Dynamic Media Service is outside of the AWS cloud. All other services are hosted in the AWS cloud.

Figure 1: Architectural Diagram – Dynamically Configuring Audio Tracks during Video File Transcoding.

In the proposed architecture, the process involves submitting video files to dynamically configure the audio track settings within the AWS Elemental MediaConvert job. To accomplish this, the user first uploads the video files to the mediaconvertstack-videotranscodingsource Amazon Simple Storage Service (Amazon S3) bucket. Then, a Java application called Dynamic Media Service is initiated, which will invoke the MediaConvert job to transcode the video files using the dynamically configured settings. The transcoded video files are then output to the mediaconvertstack-videotranscodingdestination S3 bucket for further downstream processing or use.

Please use the following steps to setup, deploy and run the test for the Java service MCDynamicAudioTest. 

Step 1: Setup the local laptop or desktop

  1. Clone the GitHub repository
  2. Complete the prerequisites:
    • Validate that you have an AWS account with credentials configured, and js and npm installed
    • Install the AWS Cloud Development Kit (AWS CDK) by using the following code: npm install -g aws-cdk
    • If AWS CDK Toolkit version is earlier than 2.140.0, then enter the following command to update it to version 2.140.0: npm install -g aws-cdk@2.140.0 --force
  3. Install CDK dependencies:
    cd cdk
    npm install
  4. Export environment variables required for the CDK stack:
    export AWS_REGION=<<region>>
    export AWS_ACCOUNT=<<account>>

Step 2: Deploy the AWS resources and run the Java service

Deploy the AWS resources using the MediaConvert CDK stack to your AWS account using the following command:

  1. This step is required for the first time to bootstrap the CDK environment, but is optional for successive deployments: npx cdk bootstrap
  2. Deploy the AWS resources using the MediaConvert CDK stack to your AWS account: npx cdk deploy

This will output the following AWS resources:

  1. mediaconvertstack-videotranscodingsource S3 bucket: Where the video files are uploaded and transcoded.
  2. mediaconvertstack-videotranscodingdestination S3 bucket: Where the video files are sent after transcoding.
  3. VideoTranscode Elemental Media Job Queue: Where the Java application submits the MediaConvert job to.
  4. VideoTranscodeRole IAM Role: The role and AWS Identity and Access Management (IAM) permissions required for the MediaConvert to run the job—required for read and write permissions to the source and destination buckets.
MediaConvert stack output: IDs of the AWS resources deployed by the stack. It includes source and destination S3 bucket names, MediaConvert job queue and the role MediaConvert assumes while running the job. They are used to set the config.properties in Steps 2-6.

Figure 2: MediaConvert Stack Outputs.

  1. Download sample video files:
  2. Respectively, rename sample files to:
    • SampleVideo-ZeroAudioTrack.mov
    • SampleVideo-MultiAudioTrack.mov
    • SampleVideo-SingleAudioTrack.mp4
  3. Log into your AWS Management Console
  4. Navigate to Amazon S3 and then Buckets
  5. Upload the newly renamed sample files to the mediaconvertstack-videotranscodingsource S3 bucket.
Media files with a different number of audio tracks uploaded to source S3 bucket for transcoding.

Figure 3: Media files in source bucket.

  1. Update the config.properties file with values for region, mcRoleArn, mcQueueArn, sourceBucket and destinationBucket obtained from the output returned upon deploying the stack in Step 2.
List of key/value pairs in config.properties. Values are set using the AWS resource IDs outputted when the MediaConvert stack is deployed.

Figure 4: Configuration Properties.

  1. Run MCDynamicAudioTest class to start transcoding of the files present in the mediaconvertstack-videotranscodingsource S3 bucket. This will engage the Dynamic Media Service to dynamically configure the number of audio tracks through a command line when transcoding the media files.
  2. Run the following test code to validate that the files have been transcoded properly:
    cd ../service
    mvn test
  3. Figure 5 represents the expected output when the tests have successfully completed.
Output of the MediaConvert job IDs when the MCDynamicAudioTest java test class is run. These Job IDs are referenced to determine the status of the jobs in the AWS console.

Figure 5: MediaConvert Transcoding Job IDs.

Step 3: Validating Transcoded Video File

  1. Check whether submitted jobs are completed:
    • Log into the AWS Management Console.
    • Navigate to AWS Elemental MediaConvert and then to Jobs.
    • Locate the Job IDs for the files submitted in Figure 5.
    • Confirm that the Job IDs all have a status of COMPLETE.
MediaConvert jobs displaying their Complete statuses after the jobs have been successfully run.

Figure 6: MediaConvert Jobs Completed.

  1. Once transcoding is done, validate the files are transcoded to the mediaconvertstack-videotranscodingdestination S3 bucket by navigating to Amazon S3 and then to Buckets.
MediaConvert transcoded media files with a different number of audio tracks in the destination S3 bucket.

Figure 7: Transcoded media files in destination bucket.

  1. Validate the number of audio tracks before and after transcoding:
    • Navigate to Media Info Online to validate the audio tracks on the transcoding video files.

Note: The transcoded version of the SampleVideo-MultiAudioTrack.mov file will have an additional audio track compared to the input media file. The original file has four tracks, while the transcoded version will have five tracks. This extra track is included to facilitate the quality assurance process. It will allow the validation of each individual track and provide the ability to listen to all the tracks when the video is played back.

    • Figure 8 validates the audio tracks count for SampleVideo-MultiAudioTrack.mov.
Side by Side comparison of the SampleVideo-MultiAudioTrack media file with multiple tracks. The left side is the media info of the file before transcoding highlighting 4 tracks. The right side is the media info of the transcoded file with 5 tracks. The extra 5th track is to hear the audio of all the tracks.

Figure 8: Transcoded media files in destination bucket.

Conclusion

We covered transcoding and the advantages it provides for customers with saving costs thru autoscaling and a Pay-as-you-go pricing model. In addition, we covered how AWS Elemental MediaConvert job settings can be dynamically configured. We then wrapped by walking through an example and illustrating how the solution provides an extra track for quality assurance.

AWS helps customers reduce operational burden so they can spend more time creating. To learn more about purpose-built solutions and services for Content Production, please visit the AWS Media and Entertainment Content Production page.

Contact an AWS Representative to know how we can help accelerate your business.

Further reading

Morris Pyle

Morris Pyle

Morris Pyle is a Senior Cloud Application Architect with over 20+ years of experience implementing and architecting large scale enterprise applications. He currently works with customers in the Media and Entertainment industry designing and implementing innovative solutions. He is passionate about helping customers deliver the perfect experience.

Rama Krishna Nagulakonda

Rama Krishna Nagulakonda

Rama Krishna is a Cloud Application Architect at AWS, wielding over 14+ years of experience in architecting, building, and deploying high-performance and secure cloud-native applications. Currently immersed in the Media & Entertainment industry, he epitomizes simplify and invent principle crafting innovative solutions that elevate industry standards.

Vijay Konda

Vijay Konda

Vijay Konda is a Cloud Application Architect with over 25+ years of expertise in architecting robust, scalable multi-tiered solutions. He is currently developing cutting-edge solutions for the Media & Entertainment Industry. Leveraging his extensive knowledge of open-source technologies, containers, serverless architectures, and more, Vijay excels at crafting innovative architectures tailored to meet the unique demands.