Recipes
Turn analysis results into ad-break candidates, credit skip intervals, a review queue and a search document.
These recipes use the result of a FINISHED analysis. Mediaseer supplies descriptions, classifications and timestamps;
your application decides how to use them. The example reads the result once and produces the sections below. It does
not start an analysis or change your video.
Ad break placement
Section titled “Ad break placement”adBreakCandidates ranks scene ends by adOpportunityInformation.score, highest first, with earlier boundaries first
on a tie. The score describes suitability at the end of the scene; a score of 0.5 can also mean the scene was
not assessed. A zero score remains a candidate in this list; the script sets no acceptance threshold.
The example requires a known video duration, scene end and score. It leaves out the beginning and end of the video; without the duration, the list is empty. Missing values do not become zero. Review the candidates, then apply your own spacing, duration and editorial rules. Your player or ad system inserts the ads; Mediaseer does not.
See AdOpportunity for the score and its explanation.
Skip intro and credits
Section titled “Skip intro and credits”skipIntervals contains scenes labelled OPENING_CREDITS or END_CREDITS with a valid start and a later end. It keeps
them as separate intervals. These are predicted scene types, so review them before using them as skip markers; an
opening scene need not cover the whole intro.
Your player can show a button while playback is inside an accepted interval and seek to its end when clicked. You
choose which intervals to offer and whether to join adjacent ones. Mediaseer returns no skip button and does not
remove those scenes. Other scene types, such as RECAP, are separate choices for your application.
See SceneType for the classifications.
Review sensitive content
Section titled “Review sensitive content”review keeps the video’s and each scene’s sensitiveTopics, and builds a shot review queue. Topic phrases are broader
than shot advisories: advisories cover tobacco and vaping imagery today, not every sensitive topic or policy.
- An
ANALYZEDshot entersshotsToReviewwhen it has detections, including low-confidence ones. Confidence helps prioritise review; it is not a reason to discard a detection. - A
BLOCKEDshot enters the queue without advisories: it was not assessed, so review it yourself. This does not mean your upload was blocked. - A shot with no advisory result enters the queue without a
status. Missing results do not mean nothing was found. hasShotBreakdown: falsemeans the scene has no shot breakdown in this result. An empty queue then says nothing about its imagery.
Only an ANALYZED shot with an empty advisory list means no advisory imagery was found in that assessment. Empty
sensitive-topic lists can also mean the analysis did not produce them. This output helps organise human review; it is
not a safety or compliance verdict.
See ShotAdvisories and the result interpretation.
Catalogue and search metadata
Section titled “Catalogue and search metadata”catalogue contains the inferred video title, description, keywords and languages, plus each scene’s title, summary,
keywords and time range when known. Unknown fields are left out. The script keeps video metadata separate from scene
metadata and leaves out analysis software metadata.
Map the analysis to your own asset identifier, review the generated text, then store or index the fields you need. Use scene timestamps to link a search hit to that part of your video. A scene identifier belongs to one result and can change when the same video is analysed again; it is not a catalogue-wide asset identifier. Mediaseer does not create a search index for you.
Run the example
Section titled “Run the example”Use bash, curl and jq, with MEDIASEER_API_URL, MEDIASEER_API_KEY and the finished ANALYSIS_ID from the
quickstart. The script keeps the key off curl’s command line and ignores your curl
configuration. Its output names, such as adBreakCandidates and shotsToReview, belong to this example, not the API
response schema.
#!/usr/bin/env bashset -euo pipefail
base="${MEDIASEER_API_URL:?the API origin, without /api/v1}"base="${base%/}/api/v1": "${MEDIASEER_API_KEY:?your API key}"id="${ANALYSIS_ID:?the id of a finished analysis}"
api() { curl -q -sS -H @- "$@" <<<"X-Api-Key: $MEDIASEER_API_KEY"; }
tmp="$(mktemp -d)"trap 'rm -rf "$tmp"' EXIT
status="$(api -o "$tmp/results.json" -w '%{http_code}' "$base/vod-analysis/$id/results")" || { echo "results got no answer: curl exit $?" >&2 exit 1}if [[ "$status" != 200 ]]; then echo "results answered $status $(jq -r '.code // empty' "$tmp/results.json" 2>/dev/null || true)" >&2 exit 1fi
jq ' def known: with_entries(select(.value != null)); .analysis as $analysis | { adBreakCandidates: ([ $analysis.scenes[] | .adOpportunityInformation.score as $score | select(($score | type) == "number" and ($analysis.duration | type) == "number" and (.endInSeconds | type) == "number" and .endInSeconds > 0 and .endInSeconds < $analysis.duration) | {sceneId: .id, atInSeconds: .endInSeconds, score: $score, reason: .adOpportunityInformation.reason} | known ] | sort_by(-.score, .atInSeconds)), skipIntervals: [ $analysis.scenes[] | select(.type == "OPENING_CREDITS" or .type == "END_CREDITS") | select((.startInSeconds | type) == "number" and (.endInSeconds | type) == "number" and .startInSeconds >= 0 and .endInSeconds > .startInSeconds) | {sceneId: .id, type, startInSeconds, endInSeconds} | known ], review: { videoTopics: $analysis.sensitiveTopics, scenes: [ $analysis.scenes[] | {sceneId: .id, sensitiveTopics, hasShotBreakdown: ((.shots // [] | length) > 0), shotsToReview: [ (.shots // [])[] | .shotAdvisories as $assessment | select($assessment.status != "ANALYZED" or ($assessment.advisories | length) > 0) | {startInSeconds, endInSeconds, status: $assessment.status, advisories: (if $assessment.status == "ANALYZED" then $assessment.advisories else null end)} | known ]} | known ] }, catalogue: ($analysis | {title, description, keywords, inputLanguageCodes, scenes: [.scenes[] | {id, title, summary, keywords, startInSeconds, endInSeconds} | known]} | known) }' "$tmp/results.json"