Skip to content

ReferenceText tracks

muxStoryboard

A converter that turns a Mux storyboard JSON file into thumbnail cues

Import

import { muxStoryboard } from '@videojs/react';

muxStoryboard reads a Mux storyboard JSON file, https://image.mux.com/{playbackId}/storyboard.json, and returns cues for a thumbnails track. Pass it as the format of a { kind: 'metadata', label: 'thumbnails' } track with a src, and the player converts the file once it loads. Or call it with the file’s text or parsed JSON and pass the result as cues.

MuxVideo already adds the storyboard as a WebVTT <track>, so you don’t need this with it. Use it when you play a Mux asset through other media, or fetch the storyboard yourself.

Usage

import { muxStoryboard, useCreateTextTrack } from '@videojs/react';

function Thumbnails({ playbackId }: { playbackId: string }) {
  useCreateTextTrack({
    kind: 'metadata',
    label: 'thumbnails',
    src: `https://image.mux.com/${playbackId}/storyboard.json`,
    format: muxStoryboard,
  });

  return null;
}

Cues

Each tile in the file’s tiles becomes one cue, in order of its start. A cue runs to the next tile’s start, and the last one to the storyboard’s duration. Tiles without a numeric start, x, and y are skipped, and a file that isn’t a storyboard gives no cues; only text that isn’t JSON throws.

Each cue’s value is a ThumbnailCueValue, which the thumbnail components read in place of a media fragment in the cue’s text:

ThumbnailCueValue field Description
url The storyboard’s sprite sheet.
width The frame’s width in pixels, from tile_width.
height The frame’s height in pixels, from tile_height.
coords The frame’s x and y offset in the sprite sheet.

Exports

Export Description
ThumbnailCueValue One thumbnail frame: an image url, and optionally its width, height, and sprite coords.