AI Logic

Evaluation Metrics

Shot Boundary Detection Evaluation

Updated:

Shot boundary detection evaluation. Top: bands along the time axis showing the ground-truth and predicted shots and transitions of a 60-frame video (2 cuts and 1 dissolve each), with the ground-truth cuts widened by 5 frames on each side. Bottom left: the one-to-one matching of transitions (cuts: TP 1, FN 1, FP 1; dissolve: TP 1). Bottom right: cut precision and recall 0.50, gradual-transition precision and recall 1.00, and fr-recall 0.75 and fr-precision 0.60 for the matched dissolve

Background and overview

Shot boundary detection evaluation measures, for the task of splitting a video into shots (units filmed continuously by a single camera), whether the changes between shots (transitions) are found correctly, using per-transition precision, recall, and F-measure. Transitions come in two kinds, evaluated separately: cuts, which switch within one frame, and gradual transitions, which take several frames or more (a dissolve, where one shot fades out while the next fades in; a fade, which goes to black and back; a wipe, which sweeps across the screen; and so on).

The standard procedure was set by the shot boundary detection task of TRECVID (2001–2007), the video retrieval evaluation campaign run by the US NIST. It has three key points.

  • Detection: a predicted transition counts as a hit if it overlaps a ground-truth transition by even one frame, and precision and recall are computed from the numbers of transitions.
  • Tolerance: a cut has zero length, so a predicted cut is treated as spanning two frames (the one just before and the one just after the change), and each ground-truth cut is widened by 5 frames on each side before matching.
  • Positional accuracy: for matched gradual transitions, the fraction of overlapping frames (frame-level precision and recall) is computed separately.

Shot segmentation is the first step of many tasks such as video retrieval, summarization, and subtitle alignment, so TRECVID ran it every year as an entry-level task. Recent deep learning methods such as TransNet V2 follow the same idea and report an F1 score that combines cuts and gradual transitions.

Definition and procedure

The TRECVID evaluation is computed as follows.

  1. Represent each predicted and ground-truth transition by its type (cut or gradual) and its start and end frames. A predicted cut is treated as spanning the two frames just before and after the change, and each ground-truth cut is widened by 5 frames on each side. Short gradual transitions of 5 frames or fewer are treated as cuts in both the ground truth and the predictions.
  2. Go through the ground-truth transitions in time order and match each one to the unmatched predicted transition of the same type with the largest number of overlapping frames (ties go to the higher frame-level precision, then to the earlier one). If the overlap is 0, that ground-truth transition is a miss (FN).
  3. Count matched pairs as TP and predictions matched to no ground truth as FP, and compute precision and recall separately for cuts and for gradual transitions. To combine them into one value, use the F-measure (their harmonic mean).
Prec=TPTP+FP,Rec=TPTP+FN,F=2ā‹…Precā‹…RecPrec+Rec\mathrm{Prec} = \frac{TP}{TP + FP}, \quad \mathrm{Rec} = \frac{TP}{TP + FN}, \quad F = \frac{2 \cdot \mathrm{Prec} \cdot \mathrm{Rec}}{\mathrm{Prec} + \mathrm{Rec}}
  1. For each matched gradual transition, compute the positional accuracy and average it per file and per submission.
fr-recall=sharedĀ framesframesĀ inĀ theĀ ground-truthĀ transition,fr-precision=sharedĀ framesframesĀ inĀ theĀ predictedĀ transition\text{fr-recall} = \frac{\text{shared frames}}{\text{frames in the ground-truth transition}}, \quad \text{fr-precision} = \frac{\text{shared frames}}{\text{frames in the predicted transition}}

In the example in the header figure, the predicted cut (17–18) is 3 frames off from the ground-truth cut (14–15), but it falls inside the ±5-frame range, so it is a hit. The predicted cut at 24–25 has no matching ground truth, so it is an FP, and the ground-truth cut at 47–48 is missed, so it is an FN. Cut precision and recall are both 0.50. For the dissolve, the ground truth (30–37, 8 frames) and the prediction (32–41, 10 frames) share 6 frames, so it is a hit, with fr-recall 6/8=0.756/8 = 0.75 and fr-precision 6/10=0.606/10 = 0.60.

A defining feature of the TRECVID evaluation is that detection (whether a transition was found) and positional accuracy (how much it overlaps) are measured with separate numbers. The TRECVID overview notes that a system can be good at detection but imprecise in position, or miss many transitions but place the ones it finds precisely. Collapsing everything into one number hides this difference.

What it measures and its limitations

Shot boundary detection evaluation measures whether shot changes are found completely without producing extra ones. Cuts and gradual transitions are separated because their difficulty is completely different. A cut changes the appearance between adjacent frames sharply and is easy to find, whereas a gradual transition is hard to distinguish from camera or object motion, and even its extent is ambiguous.

It has the following limitations.

  • Offsets within the tolerance are invisible: a cut counts as a hit anywhere within ±5 frames, so positional accuracy inside that range is not evaluated. The tolerance exists to absorb differences in how decoders number frames.
  • Difficulty depends heavily on the mix of transitions in the data: in the TRECVID test data, cuts made up 48.7% of transitions in 2006 and 90.8% in 2007. Values from different years cannot be compared directly.
  • The handling of short gradual transitions affects the value: gradual transitions of 5 frames or fewer are treated as cuts. According to Smeaton et al., these short transitions increased over the years and accounted for 47% of gradual transitions in 2006.
  • The tolerance and matching used for evaluation differ between papers: most recent papers report F1 scores with their own evaluation scripts rather than the TRECVID evaluation code.

Recent F1 scores are not comparable across different evaluation scripts. The TransNet V2 paper found that the evaluation code of one compared method did not match its own evaluation procedure, so it re-evaluated all compared methods with the same script. That evaluation counts offsets of up to 2 frames from the ground-truth position as hits. The paper also notes that the thresholds of the compared methods were chosen as the best values on the test set, so their performance may be overestimated. When comparing values, align the tolerance, the handling of transition types, and how thresholds are chosen.

Results at TRECVID

The paper by Smeaton et al. (2010) summarizes seven years of the TRECVID shot boundary detection task. The test data each year was 4.8–7.5 hours of video with 2,090–4,806 transitions. Among the top 10 groups in 2005, the best runs of the top 3 were as follows.

Transition typeGroupRecallPrecisionF-measure
CutKDDI0.9360.9490.942
CutTsinghua U.0.9300.9410.936
CutNICTA0.9470.9140.930
GradualTsinghua U.0.7880.7910.790
GradualNICTA0.7730.7810.777
GradualIBM0.8380.7220.776

For cuts, 7 of the top 10 groups exceeded an F-measure of 0.9, whereas for gradual transitions even the best was 0.790.

The same paper also shows the F-measure of an almost unchanged system (CLIPS-IMAG / LIG) evaluated on each year's data. Even without changing the system, the value moves a lot with the data.

YearCutGradual
20030.9170.774
20040.8660.767
20050.9110.763
20060.7800.512
20070.947―

Gradual transitions for 2007 are omitted because there were too few of them. The paper states that the 2006 data was the hardest for both cuts and gradual transitions, and the 2007 cuts were the easiest.

Where it is used

Shot boundary detection evaluation is mainly used in the following situations.

  • Comparing shot boundary detection methods: in addition to the TRECVID data, recent work compares F1 scores on datasets such as ClipShots, BBC Planet Earth, and RAI. The TransNet V2 paper reports the following F1 scores, combining cuts and gradual transitions.
ModelClipShotsBBCRAI
TransNet73.592.994.3
TransNet V277.996.293.9
  • Checking the quality of a video processing front end: video retrieval, summarization, and scene indexing often use shots as the processing unit, so errors in segmentation propagate to later stages.
  • Tuning the threshold: for models that output a per-frame transition score, changing the threshold trades precision against recall. At TRECVID, too, groups explored the precision-recall trade-off through multiple runs with different settings.

Comparison with similar metrics

The table compares shot boundary detection evaluation with metrics that evaluate time segments, from the same viewpoints.

MetricUnit evaluatedHit conditionPositional accuracyRange
Transition precision and recall (TRECVID)Transitions (cuts and gradual separately)Overlap of at least 1 frame (±5 frames for cuts)Not considered0–1
fr-recall and fr-precision (TRECVID)Matched gradual transitions―Measured by the fraction of shared frames0–1
F1 with toleranceTransitions (types often combined)Offset within a set number of framesNot considered0–1 (often written in %)
F1@kSegmentsSame label with IoU ≄ k%Considered more as k grows0–100
Edit scoreSequence of segment labelsAligned by edit distanceNot considered0–100

Shot boundary detection evaluates the "boundaries between segments" rather than the "segments" themselves, so hits are decided by overlap or tolerance instead of IoU. In every metric, hits are counted the same way as precision and recall for the F1 score.

Rough guidelines for choosing:

  • Comparing with prior work on TRECVID data: compute precision and recall separately for cuts and gradual transitions, and also report fr-recall and fr-precision for gradual transitions.
  • Comparing with deep learning methods on recent datasets: compute the F1 score with the same evaluation script (tolerance and transition handling) as the papers being compared.
  • Evaluating meaningful scenes or action segments rather than shots: use F1@k, which looks at the overlap between segments.

PyTorch example

Show code
python
import torch


def transitions_from_scores(scores, threshold=0.5):
  """Turn runs of frames whose per-frame transition score (a 1-D tensor) exceeds the threshold into transitions
  (the same rule as the TransNet V2 paper). Returns a list of (start, end (inclusive))."""
  on = (scores > threshold).int()
  diff = torch.diff(torch.cat([torch.tensor([0]), on, torch.tensor([0])]))
  starts = (diff == 1).nonzero().flatten().tolist()
  ends = ((diff == -1).nonzero().flatten() - 1).tolist()
  return list(zip(starts, ends))


def trecvid_sbd(ref, sub, tol=5):
  """TRECVID evaluation. ref and sub are lists of (type, start, end (inclusive)). type is "cut" or "grad".
  A cut is represented by the two frames just before and after it, (f, f + 1). Gradual transitions of 5 frames or fewer are treated as cuts."""
  norm = lambda t: ("cut" if t[0] == "grad" and t[2] - t[1] + 1 <= 5 else t[0], t[1], t[2])
  ref, sub = sorted(map(norm, ref), key=lambda t: t[1]), sorted(map(norm, sub), key=lambda t: t[1])
  overlap = lambda a, b: max(0, min(a[2], b[2]) - max(a[1], b[1]) + 1)
  used, match = [False] * len(sub), []
  for r in ref:  # go through ground-truth transitions in time order
    rr = (r[0], r[1] - tol, r[2] + tol) if r[0] == "cut" else r  # widen ground-truth cuts by tol frames on each side
    cand = [(overlap(rr, s), overlap(r, s) / (s[2] - s[1] + 1), -j, j)
            for j, s in enumerate(sub) if not used[j] and s[0] == r[0] and overlap(rr, s) > 0]
    if cand:
      j = max(cand)[3]  # largest overlap -> frame-level precision -> earliest
      used[j] = True
      match.append((r, sub[j]))
    else:
      match.append((r, None))
  result = {}
  for kind in ("cut", "grad"):
    tp = sum(1 for r, s in match if r[0] == kind and s is not None)
    fn = sum(1 for r, s in match if r[0] == kind and s is None)
    fp = sum(1 for j, s in enumerate(sub) if s[0] == kind and not used[j])
    prec = tp / (tp + fp) if tp + fp else 0.0
    rec = tp / (tp + fn) if tp + fn else 0.0
    f = 2 * prec * rec / (prec + rec) if prec + rec else 0.0
    result[kind] = dict(tp=tp, fp=fp, fn=fn, precision=prec, recall=rec, f=f)
  # positional accuracy of matched gradual transitions (mean over transitions)
  g = [(r, s) for r, s in match if r[0] == "grad" and s is not None]
  if g:
    result["fr_recall"] = sum(overlap(r, s) / (r[2] - r[1] + 1) for r, s in g) / len(g)
    result["fr_precision"] = sum(overlap(r, s) / (s[2] - s[1] + 1) for r, s in g) / len(g)
  return result


# example from the header figure (60 frames)
ref = [("cut", 14, 15), ("grad", 30, 37), ("cut", 47, 48)]
sub = [("cut", 17, 18), ("cut", 24, 25), ("grad", 32, 41)]
print(trecvid_sbd(ref, sub))
# cut: TP 1, FP 1, FN 1 (precision and recall 0.5), grad: TP 1 (1.0), fr_recall 0.75, fr_precision 0.6

scores = torch.tensor([0.1, 0.2, 0.9, 0.8, 0.1, 0.05, 0.7, 0.1])
print(transitions_from_scores(scores))  # [(2, 3), (6, 6)]

FAQ

Q. Why are cuts and gradual transitions evaluated separately?
A.

Because their difficulty is completely different. Cuts change the appearance between adjacent frames sharply and are easy to find; at TRECVID 2005 most of the top groups exceeded an F-measure of 0.9. Gradual transitions are hard to distinguish from camera or object motion, and even the best reached only 0.790. A single combined value would hide weakness on gradual transitions in data dominated by cuts.

Q. Why is the cut tolerance 5 frames?
A.

TRECVID widens each ground-truth cut by 5 frames on each side to absorb differences in how video decoders number frames. It is not meant to measure positional accuracy, so offsets inside the tolerance do not show up in the evaluation.

Q. Can F1 scores from different papers be compared directly?
A.

Only when the evaluation conditions match. The value changes with the allowed offset in frames, whether cuts and gradual transitions are combined, and how the threshold was chosen. The TransNet V2 paper re-evaluates all compared methods with the same script before comparing them.

References

  1. Smeaton, A. F., Over, P., & Doherty, A. R. (2010). Video shot boundary detection: Seven years of TRECVid activity. Computer Vision and Image Understanding, 114(4), 411–418 (version in the DCU repository).
  2. NIST. TRECVID 2002 Shot Boundary (SB) Measures.
  3. Over, P., Awad, G., Kraaij, W., & Smeaton, A. F. (2007). TRECVID 2007 – Overview (Section 3, Shot boundary detection).
  4. Souček, T., & Lokoč, J. (2020). TransNet V2: An effective deep network architecture for fast shot transition detection. arXiv:2008.04838.
  5. soCzech/TransNetV2 (public code, evaluate_scenes in training/metrics_utils.py).