Programmable Media

Amazon Rekognition Video Moderation

Last updated: Dec-11-2024

Cloudinary is a cloud-based service that provides an end-to-end media asset management solution including uploads, storage, transformations, optimizations and delivery. Cloudinary offers a very rich set of transformation and analysis capabilities, and allows you to upload images and videos to the cloud, transform them on the fly and deliver them to your users optimized and cached via a fast CDN.

Amazon Rekognition is a service that makes it easy to add video analysis to your applications. Cloudinary provides an add-on for Amazon Rekognition's video moderation service based on deep learning algorithms, fully integrated into Cloudinary's video management and transformation pipeline.

With Amazon Rekognition's AI Moderation add-on, you can extend Cloudinary's powerful cloud-based transformation and delivery capabilities with automatic artificial intelligence based moderation of your videos. Protect your users from explicit and suggestive adult content in your user uploaded videos, making sure that no offensive videos are displayed to your web and mobile viewers.

Getting started

Before you can use the Amazon Rekognition Video Moderation add-on:

  • You must have a Cloudinary account. If you don't already have one, you can sign up for a free account.

  • Register for the add-on: make sure you're logged in to your account and then go to the Add-ons page. For more information about add-on registrations, see Registering for add-ons.

  • Keep in mind that many of the examples on this page use our SDKs. For SDK installation and configuration details, see the relevant SDK guide.

  • If you're new to Cloudinary, you may want to take a look at the Developer Kickstart for a hands-on, step-by-step introduction to Programmable Media features.

Automatic video moderation flow

The following list describes the flow of uploading and displaying moderated videos using Cloudinary and the Amazon Rekognition's AI Moderation add-on:

  1. Your users upload a video to Cloudinary through your application.
  2. The uploaded video is sent to Amazon Rekognition for moderation and set to a 'pending' status.
  3. The video is either approved or rejected by Amazon Rekognition.
  4. An optional notification callback is sent to your application with the video moderation result.
  5. A rejected video does not appear in your media library, but is backed up, consuming storage, so that it can be restored if necessary.
  6. Moderated videos can be listed programmatically using Cloudinary's Admin API or interactively using our online Media Library Web interface.
  7. You can manually override the automatic moderation using the Admin API or the Media Library.

Note
By default, assets that are marked for moderation are deliverable and available via the Media Library. If you'd like the assets marked for moderation to be blocked (until approved) either from the Media Library, or from being delivered, or from both, contact support.

Moderation categorization

Amazon Rekognition assigns a moderation confidence score (0 - 100) indicating the chances that a video belongs to an offensive content category.

There are two levels of categories for labelling unsafe content, with each top-level category containing a number of second-level categories, for example under the 'Violence' (violence) category you have the sub-category 'Physical Violence' (physical_violence). A full list of all the latest available categories and sub-categories is provided by AWS, see Amazon Rekognition categories.

The top level categories include:

  • Explicit Nudity (explicit_nudity)
  • Suggestive (suggestive)
  • Violence (violence)
  • Visually Disturbing (visually_disturbing)
  • Rude Gestures (rude_gestures)
  • Drugs (drugs)
  • Tobacco (tobacco)
  • Alcohol (alcohol)
  • Gambling (gambling)
  • Hate Symbols (hate_symbols)

Note
When referring to the categories in your code, replace spaces with underscores and upper case letters with lower case letters (e.g., 'Illustrated Nudity Or Sexual Activity' becomes illustrated_nudity_or_sexual_activity).

The default moderation confidence level to reject a video is 0.5 for all categories, unless specifically overridden (see explanation and examples below). All videos classified by Amazon Rekognition with a value greater than the moderation confidence level (in any of the categories) are classified as 'rejected', otherwise their status is set to 'approved'.

Request video moderation

To request moderation while uploading a video, with default moderation confidence levels, set the moderation upload API parameter to aws_rek_video:

Tip
You can use upload presets to centrally define a set of upload options including add-on operations to apply, instead of specifying them in each upload call. You can define multiple upload presets, and apply different presets in different upload scenarios. You can create new upload presets in the Upload Presets page of the Console Settings or using the upload_presets Admin API method. From the Upload page of the Console Settings, you can also select default upload presets to use for image, video, and raw API uploads (respectively) as well as default presets for image, video, and raw uploads performed via the Media Library UI.

Learn more: Upload presets

You can also optionally:

  • Override the default moderation confidence level (0.5) on a per category basis by including the category name and new value as part of the moderation parameter value. You can override multiple categories, separated by colons.
    Note
    Overriding the default moderation confidence value of a top-level category will also set all its child categories to the same value, unless you specifically override one of the child categories as well.
  • Exclude a category from the moderation check by setting the category's value to ignore.
  • Return the moderation_labels array, even if no offending content is found by setting: aws_rek:min_confidence:0.0

Example

  • Set the Female Swimwear or Underwear child category to a minimum confidence level of 0.85
  • Set the Explicit Nudity top-level category to 0.7. This then becomes the confidence level for all its child categories as well.
  • Exclude the Revealing Clothes category from the check.
  • Check all other categories at the default 0.5 confidence level.

Notes
  • Confidence levels must be provided as a decimal number between 0.0 and 1.0.
  • Videos must have a minimum height and width of 80 pixels.

Moderation response

As moderation is processed asynchronously, the initial upload response will include a moderation parameter indicating the status and kind of moderation:

Once the moderation is complete, you will receive a notification indicating the results of the request for moderation. The snippet below shows that the moderation result has put the video in 'rejected' status.

Note
Only the first 1000 moderation_labels are returned in the response but all of them are taken into account for moderation.

Video moderation listing

Cloudinary's Admin API can be used to list all moderated videos. You can list either the approved or the rejected videos by specifying the second parameter of the resources_by_moderation API method. For example to list all rejected videos:

Manual override

As the automatic video moderation of the Amazon Rekognition AI Moderation add-on is based on a decision made by an advanced algorithm, in some cases you may want to manually override the moderation decision and either approve a previously rejected video or reject an approved one.

Overriding moderation via the Media Library

One way to manually override the moderation result is using Cloudinary's Media Library Web interface. From the left navigation menu, select Moderation. Then, from moderation tools list in the top menu, select Rekognition and then select the status (Rejected, or Approved) of the videos you want to display.

  • When displaying the videos rejected by Amazon Rekognition, you can click on the green Approve button to revert the decision and recover the original rejected video.
  • When displaying the videos approved by Amazon Rekognition, you can click on the red Reject button to revert the decision and prevent a certain video from being publicly available to your users.

Overriding moderation via the Admin API

Alternatively to using the Media Library interface, you can use Cloudinary's Admin API to manually override the moderation result. The following example uses the update API method while specifying a public ID of a moderated video and setting the moderation_status parameter to the rejected status.

✔️ Feedback sent!

Rate this page: