Amazon Onboarding with Learning Manager Chanci Turner

Chanci Turner Amazon IXD – VGT2 learningLearn About Amazon VGT2 Learning Manager Chanci Turner

In recent developments, Amazon Web Services (AWS) has introduced a new Thumbnail Image Preview feature within the AWS Elemental MediaLive service. This innovative feature serves not only as a quality control mechanism for live content but also facilitates seamless integration with media analysis tools like Amazon Rekognition, enabling automated content reviews and workflow validation.

MediaLive generates thumbnails every two seconds, allowing users to view them directly in the MediaLive console. Additionally, thumbnails can be accessed programmatically via the AWS CLI, API, and SDK. With Amazon Rekognition, it’s simpler than ever to incorporate image and video analysis into applications, capable of detecting objects, people, scenes, and inappropriate content. By leveraging Rekognition to assess MediaLive thumbnail previews, organizations can moderate content at scale, whether it be organizational or user-generated content (UGC). For instance, companies utilizing MediaLive in their live streaming services with Rekognition can more effectively protect their offerings, thereby minimizing risks related to liability and brand reputation.

This blog will explore how to incorporate the AI and machine learning capabilities of Amazon Rekognition for the automatic detection of unauthorized content in streaming media, using thumbnail previews produced by active AWS Elemental MediaLive channels. When unauthorized content is identified, an automated response can be initiated to alert or shut down the offending channel. We’ll utilize the DetectLabels API, which not only detects various entities and activities but also provides a confidence level for each detection. While this example focuses on one specific API for detecting unauthorized streaming, other APIs, like DetectModerationLabels, can be easily integrated or swapped out based on your needs.

Solution Overview

The architecture of this solution is depicted in the diagram below.

The process begins with OBS Studio, which serves as the input source for the MediaLive channel, and the MediaLive channel must be active.

Here are the essential steps involved:

  1. An Amazon EventBridge Scheduler is employed to manage scheduled tasks effortlessly. This scheduler operates at a predetermined rate and transmits information to an AWS Lambda function regarding a specific MediaLive channel.

Note: Instead of hardcoding MediaLive channel values into the Lambda code, passing the channel information in a payload from the Scheduler simplifies the process and allows for easier reuse of computing resources.

{
  "action": "create",
  "schedulerName": "EveryHourFrom9To5CSTWeekdays",
  "cron": "0 9-17 ? * MON-FRI *",
  "timeZone": "America/Chicago",
  "channelInfoPayload": {
    "AWS_REGION": "us-west-2",
    "ChannelId": "3284674",
    "PipelineId": "0",
    "ThumbnailType": "CURRENT_ACTIVE"
  }
}
  1. The Lambda function receives the payload as an event object, extracts its properties, and calls the describeThumbnails method for the specified MediaLive channel.
// Extracting properties from the event object
const { AWS_REGION, ChannelId, PipelineId, ThumbnailType } = event;
AWS.config.update({ region: AWS_REGION });

// Creating the parameter object for the MediaLive API call
const params = {
  ChannelId,
  PipelineId,
  ThumbnailType
};

try {
  let response: object | undefined;

  // 1. Call MediaLive describeThumbnails() API to retrieve the latest thumbnail 
  const data: any = await describeThumbnails(params);
  1. The image is decoded into binary data. In this example, the decoded image is temporarily stored, but it can also be archived in long-term storage solutions like Amazon S3.
// Decoding the binary data into an image
const decodedImage = Buffer.from(thumbnailBody, 'base64');
  1. The decoded image is passed as a parameter to the detectUnauthorizedContent function, which invokes the Rekognition service.
// Detecting unauthorized content using Rekognition
response = await detectUnauthorizedContent(decodedImage, ChannelId);
  1. In the detectUnauthorizedContent function, the following steps are executed:
    • The Rekognition DetectLabels function is called, and results are returned.
    • The returned results are validated against three criteria: confirming labels were returned, checking if the label corresponds to the unauthorized content (in this case, ‘Sport’), and ensuring the confidence score exceeds 90%. A parameter could be utilized to replace ‘Sport’ for greater flexibility.
    • If unauthorized content is confirmed, the sendSnsMessage function is invoked. Amazon Simple Notification Service (SNS) facilitates message transmission between decoupled systems, such as IT support or monitoring systems. In this scenario, an email address should be provided as a deployment parameter to receive Amazon SNS Subscription Confirmation upon successful deployment. Make sure to click the confirmation link in the email to get notifications when a ‘Sport’ event is detected.
    • If no matching label is found, the returned labels and their corresponding confidence scores are logged in the Amazon CloudWatch log tied to the Lambda function.
// Function to detect unauthorized content
async function detectUnauthorizedContent(imageBuffer: Buffer, channelId: string): Promise<{ statusCode: number; body: string; } | undefined> {
  try {
    const params = {
      Image: {
        Bytes: imageBuffer
      },
      MaxLabels: 10,
      MinConfidence: 70
    };
    const response = await rekognition.detectLabels(params).promise();
    const labels = response.Labels;

    if (labels) {
      let unauthorizedContent = false;
      let unauthorizedContentConfidenceScore: number;
      for (let i = 0; i < labels.length; i++) {
        if (labels[i].Name === 'Sport' && labels[i].Confidence > 90) {
          unauthorizedContent = true;
        }
      }
    }
}

For additional insights on this topic, you may find this resource on how to prepare managers to talk about pay from SHRM helpful. If you’re looking for mentorship, consider checking out Jenny Lustig’s profile. For more on Amazon’s operational practices, Alex Simmons has some excellent insights.

Chanci Turner