Audio and video moderation

AudioPreview · VideoPreview

Audio and video uploads always return with classification.moderation.status pending and run in the background, including when wait=true. Retrieve the asset or receive the decision through a webhook, as described in Waiting for the decision.

Each upload gets one of two analyses:

AnalysisWhen it runsResults and coverage
Category analysisYour policy has no allowances or restrictions, the upload has no conversation context, and no mandatory rule could act on the category scores.Category scores and approximate evidence ranges. No qualifier scores or retained speech transcript.
Detailed analysisYour policy has allowances or restrictions, the upload is a reply in a conversation, or a mandatory rule could act on a category the clip scores in.Category and qualifier scores for each group of video frames, including their visible text, and for the speech transcript, with how the whole clip frames what they show. Non-speech sounds are not assessed, except when category analysis ran first because of a mandatory rule: its category scores are kept alongside.

Coverage and limits

  • Before billing is set up, audio and video uploads can be up to 50 MiB and 120 seconds. Once billing is set up, they can be up to 30 minutes, and files over 50 MiB, up to 2 GiB, are sent as a multipart upload. An upload in one request stays at 50 MiB, and a remote URL import at 20 MiB. Media longer than 120 seconds is analysed in sections.
  • Media has one audio track, of at most eight channels, and one video track. Video resolution is at most 8,847,360 pixels (4096 × 2160).
  • Subtitle tracks are moderated as text, every cue of every track, and billed as text moderation. Subtitles drawn as pictures (such as DVD or Blu-ray subtitles) and closed captions carried inside the video stream can't be read, so media with them fails with unsupported-format.
  • Pictures embedded in the file, such as album or cover art, are moderated as images, each distinct picture once, and billed as image moderation, one for each group of up to eight. Media with more than 16 distinct pictures fails with too-many-items.
  • Media is analysed to the end of its longest track, whatever duration its file declares, and the browser-safe file CalmLens makes from it is no longer than what was analysed.
  • Video is sampled at two frames per second in category analysis, or once per second in detailed analysis. In detailed analysis, sampled frames that show something new are judged in groups of up to eight consecutive frames, and their moderation also reads visible text. How the whole clip frames what they show, such as news reporting, fiction or education, is then judged once from up to eight frames spread across the clip and its speech transcript. A frame that shows nothing new, in brightness or colour, since the previous one isn't analysed again.
  • Every frame of a video is checked for scenes too brief to be sampled, such as a flash between samples or a quick cut. A frame of each one is judged as well, in groups of up to eight frames. Video with more of these scenes than it has seconds fails with too-many-items.
  • Audio is mixed to one channel for analysis, unless mixing would lose a channel's content, as with channels in opposite phase or carrying different sounds. Each channel of that stretch of the media is then analysed and transcribed on its own.
  • Small text, ambiguous sounds and changes too gradual to start a new scene can be missed. Context spanning different evidence ranges may also be missed. Whether flashing or strobing could trigger seizures in people with photosensitive epilepsy isn't assessed; check for it yourself if your users can upload such video.
  • Evidence locations are approximate ranges, not word-level timestamps. Scores are not probabilities of correctness; see Reading classification results.
  • Unsupported, corrupt or over-limit media, or a failure to complete analysis, ends with classification.status failed. Unsupported, corrupt and over-limit media fail without retrying, and classification.failureReason says why (see Failure reasons); temporary failures are retried automatically first. A partial result never approves the asset, and media that fails isn't billed. Follow Recover from processing failure before retrying or replacing it.

Long audio and video

Long audio and videoPreview

With billing set up, media longer than 120 seconds is analysed in sections of 30 seconds, each starting one second before the previous one ends, with the same analysis a shorter upload gets. In detailed analysis, the speech transcript is moderated once for the whole media, and how the media frames what it shows is judged across all of it.

While sections run, classification.status is processing and classification.progress reports completedSections of totalSections; it is null for other assets and once analysis ends. The asset.progress-updated event reports the same numbers every tenth of the sections or 30 seconds, whichever comes first. The decision follows, with its usual event, once every section is done.

A section the media processor rejects, such as one it can't decode, fails the whole asset with its reason in classification.failureReason. Other failures are retried automatically, and a section that still can't be analysed fails the asset with processing-error. Usage limits lists how much long media each organisation can analyse at once and each day, and how spend limits apply.

Findings timeline

Findings timelinePreview

A decided audio or video asset has a findings timeline: segments that each give the scores for one stretch of the media. classification.moderation.timeline.segmentCount says how many there are, and GET /projects/:projectId/assets/:assetId/timeline (client.assets.listTimeline({ assetId })) pages through all of them in time order. classification.moderation.timeline is null for other assets and before there are findings.

let cursor: string | undefined;
do {
  const page = await client.assets.listTimeline({ assetId, cursor, pageSize: 100 });
  for (const segment of page.items) {
    console.log(segment.source, segment.startSeconds, segment.endSeconds);
  }
  cursor = page.nextCursor ?? undefined;
} while (cursor);
sourceCovers
clipCategory analysis: an approximate evidence range, or one channel of it analysed on its own. Ranges may overlap.
frameDetailed analysis: one group of up to eight frames that show something new, extended over the following samples that show nothing new. In either analysis, a group of frames from scenes too brief to be sampled.
speechDetailed analysis: the whole speech transcript.
frame-textThe media's subtitles, across the whole media, and a project's test phrases read from frames while test inputs are on.

Start and end times are in seconds from the start of the media and locate evidence approximately. The timeline is replaced when the asset is analysed again, kept when its content is removed, and deleted with the asset. While a safety hold is on the endpoint returns 423 asset/held, and while a copyright hold is on it lists nothing. The portal shows the same segments in the asset's analysis timeline.

Reports, retention and usage

The transcript is available as content.extractedText when the upload sets processingOptions.keepContentAfterProcessing. Purging removes retained originals and transcripts, subject to safety holds. Analysis samples are not available as child assets.

Billing depends on the analysis:

  • Category analysis: text-moderation token usage, with a minimum of 250 tokens per analysis section. Sections cover up to 30 seconds with a one-second overlap; billed usage includes repeated context and analysis overhead. A 30-second section of video uses about 10,100 tokens and of audio about 5,300, so an hour of video uses about 1.25 million tokens and an hour of audio about 0.66 million. A section whose channels are analysed one by one uses those tokens again for each channel after the first, as audio. Each group of up to eight frames from scenes too brief to be sampled is one image moderation. OCR is not charged separately.
  • Detailed analysis: image moderation for each group of up to eight sampled frames that show something new or frames from brief scenes, plus one for the media's framing when its frames or speech find something whose framing your policy reads, and text moderation for the speech transcript of each channel analysed. The cost per hour depends on how often the picture changes. Frames are not charged for OCR. When category analysis ran first because of a mandatory rule, both analyses are billed.

Long media is billed once, when every section is done. Media that fails isn't billed.

See Pricing for rates and free allowances.

Tested audio formats include WAV, MP3, FLAC, AAC, M4A (AAC/ALAC), Ogg/Vorbis, Opus, AIFF and WMA. Tested video formats include MP4 with H.264/HEVC, MOV with H.264, WebM with VP8/VP9/AV1, Matroska, AVI, MPEG, MPEG-TS and WMV. Upload with the appropriate concrete audio/* or video/* MIME type; changing a filename or MIME type cannot make an unsupported codec decodable.

Show audio and video in your app

Browser-safe media, posters and waveformsPreview

Once an audio or video asset whose content is kept is decided, CalmLens serves a browser-safe file at its rendered resource and a still image at its preview resource:

Typerenderedpreview
VideoMP4 with H.264 video and AAC audio, scaled down to fit 1080p. An upload that is already H.264 and AAC in MP4 or QuickTime, up to 1080p, is served as uploaded.A poster: the frame on screen one second in, as moderation sampled it, or the first frame of shorter video.
AudioAAC in M4A. MP3, AAC, M4A and Opus in Ogg uploads are served as uploaded.A waveform image.

content.rendered and content.preview are null until they are made. content.rendered.kind is video or audio, and audio's content.rendered.peaks holds up to 512 loudness peaks from 0 to 1, evenly spaced over the audio, so you can draw your own waveform and its progress. The rendered file answers Range requests, so players can seek; the original stays available at original. The preview takes lenses and transforms like any image, and its thumbhash and averageColor make a placeholder while the player loads. See What the CDN serves for every asset type.

For a private asset, sign its asset URL on your server and send it to the browser; the rendered file and the preview are paths beneath it:

// One signed asset URL covers every resource beneath it: the displayable file, such as
// browser-safe video, and the still image that stands for it.
const { url } = await client.cdn.signAssetUrl({ assetId, expiresIn: 900 });
const rendered = `${url}/rendered`;
const preview = `${url}/preview`;
console.log(rendered, preview);

Then use the rendered URL as a <video> or <audio> source and the preview as the video's poster. The JavaScript SDK's asset component does this for you: it plays video with its poster and audio under its waveform, and fetches a fresh signed asset URL from your server when the one in use expires.

To adapt playback to each viewer's connection, or to embed media in other sites, turn on streaming: CalmLens then also prepares an adaptive HLS stream from the browser-safe file, and serves an embed page for iframes.

Animated images

Animated GIF, WebP and PNG (APNG) images, and AVIF and HEIF image sequences, are uploaded as images, and their frames are moderated like video frames in detailed analysis. A PNG with an animation is moderated as one whatever its MIME type, even when the animation has a single frame. The image itself, its still, is moderated as an image; the first frame is moderated again when it shows something else, such as a PNG's default image that isn't part of its animation, or a sequence's first track that differs from its still. Every track of an image sequence is moderated.

Every frame of an animation that shows something new, in brightness or colour, is judged when there are up to 120 of them. A longer animation is moderated by what it shows at every half second of display time, which includes every frame shown for half a second or more, and by a frame of each scene too brief to be on screen at one of those moments; frame delays of 10 ms or less count as 100 ms, as browsers show them. An animation that needs more than 120 frames this way is too large to sample. Frames are judged in groups of up to eight. Each frame judged is also checked for your project's test images. Processing features, such as OCR and link detection, and hash matching use the still only.

The image's decision covers every frame it judged, and its report merges their findings. Animations too large to sample, such as those whose frames hold more than 400 million pixels in all or that need more than 120 frames judged, fail with classification.status failed.

Last updated

Signing in

Signing out

Cookies on CalmLens

We use essential cookies for sign-in and security. With your permission, functional cookies remember your preferences and Google Analytics measures website use and signups. Optional ad measurement cookies link Google ad clicks to signups. Personalised advertising stays off. Manage cookies