Colourways Plugin

mp4e:colourways lets viewers pick a colour for the garments on screen and recolours them live in the video.

Overview

Colourways (mp4e:colourways, an official plugin) keeps the colours the viewer chose for the garments in a video and shows a selector for the look on screen. A swatch picked in the selector recolours the garment in the footage itself, at once and while the video plays, to exactly that colour. Colourways pairs with the Atelier card, whose swatches pick the same colours, but works on its own as a selector.

Colourways is a family plugin: it has the family's six themes, its common style settings, its minimum readable size and its keyboard and TV-remote navigation.

Adding colourways to a video

  1. Track each garment as an object.
  2. Install Colourways from the marketplace and add one Colourways overlay covering the whole timeline. It covers the whole frame and places its own selector, so do not resize it.
  3. Describe the looks (below): which garments belong together and which colours to offer.
  4. Give each garment a replacement zone that follows it, with contentType recolor, recolorMode colour and its target colour read from Colourways' variable (below).
  5. Pick a theme and a size. Lean-back is for a TV across the room.

A recolour zone in colour mode gives every pixel of the garment the exact target colour, keeping the folds and shading of the fabric; black and white are exact too. recolorSourceLightness is how light the garment is in the footage: "auto" (the default) measures it on every frame from the garment's soft matte when the garment has been prepared for replacement, so a light colour stays true when the light changes; a number from 0 to 1 fixes it for the whole zone. A piece the viewer has not recoloured has no entry in the state, the zone's target resolves to empty and the zone draws nothing, so the garment shows as filmed.

A recolour zone for one garment
{
  "type": "core:replacement_zone",
  "config": {
    "zoneMode": "tracked", "trackedObjectId": "obj_2", "trackingShapeMode": "polygon",
    "contentType": "recolor",
    "recolorMode": "colour",
    "recolorTargetColor": "{{mp4e:colourways:state.obj_2.hex}}",
    "recolorSourceLightness": "auto"
  }
}

Looks

A look is an outfit: the garments that appear together and the colours the viewer can choose for them. In a linked look (the default) one pick recolours every garment of the look, whether it was picked in the selector or on the garment's Atelier card; in an unlinked look each garment has its own colour.

PropTypeDefaultDescription
idstring-The look's id. Required.
namestring-The look's name, shown in the strip and the chip's palette ("Coral Tide").
labelstring-The short label on the rail ("Look 01").
linkedboolean-Default true: a colour picked for the look is applied to every piece. false: a pick changes only the piece it was picked for.
pieces{ objectId, name, colourways? }[]-The tracked objects (garments) of the look. An unlinked look's piece may carry its own colourways.
colourways{ id, name, hex }[]-The colours to choose from; hex is #rrggbb. The first swatch shown is always Original, the colour of the video.
looks
[
  { "id": "look01", "name": "Coral Tide", "label": "Look 01",
    "pieces": [ { "objectId": "obj_2", "name": "Top" }, { "objectId": "obj_1", "name": "Bottom" } ],
    "colourways": [
      { "id": "sage",       "name": "Sage",       "hex": "#9fb8a4" },
      { "id": "terracotta", "name": "Terracotta", "hex": "#c46a4e" },
      { "id": "noir",       "name": "Noir",       "hex": "#111111" }
    ] }
]

Settings

Colourways' own settings, plus the family's common style settings (theme, accent, size, surface, textColor, font, radius, motion):

PropTypeDefaultDescription
looksLook[] | string[]The looks (shape below). Also JSON text, so a single {{variable}} can supply the whole list.
style'rail' | 'strip' | 'chip' | 'none''rail'The selector: a slim capsule on the frame edge, a bar along the bottom with the look's name, a corner pill that opens the palette, or none (Colourways keeps the choices and something else, such as the Atelier card, picks the colour).
position'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''left'Rail: left or right. Strip: always bottom centre. Chip: a corner (left and right mean the top corners).
pins{ lookId, start, end }[][]Show a look during a range of seconds whatever is on screen.

How it behaves

  • The selector follows the look on stage. It shows the largest look on screen; another look takes over once it has been the largest for half a second. A pin shows its look at once. When no look is on screen the selector fades out.
  • The first swatch is always Original, the colour of the video. Picking it removes the recolour.
  • Choices last for the viewing session, also when the video loops.
  • Tappable while the video plays. Only the selector takes the pointer (through clickable regions); every click elsewhere goes through to the video and the garments.
  • On a phone-sized player the rail and the strip become the corner chip; on a short player (a phone in landscape) the rail first drops its label, then takes two columns, so every swatch shows.
  • While the chip's palette is open, the first tap outside it only closes it.
  • On a very small player (a video inline on a phone held upright) the open palette is one row of swatches beside the chip, which scrolls sideways when the look has many colours.
  • A keyboard or TV remote moves between the swatches with the arrows; Enter picks and Back leaves.

Actions

Through pluginAction from rules, other plugins and input shortcuts, or callPluginAction from your page:

PropTypeDefaultDescription
select{ lookId, colourway, objectId? }-Choose a colour: every piece of a linked look, or the piece named by objectId in an unlinked one. colourway "original" goes back to the video's own colour. Answers { selected, objectIds }. In its first moments (up to 1.5 s, while it reads the colours already chosen) it answers { selected: false, queued: true, objectIds: [] } and applies the choice as soon as that read is done: queued is not a refusal.
reset{ lookId? }-Back to the video's own colours for one look, or for every look when lookId is empty. Answers { reset, objectIds }; in its first moments, like select, { reset: false, queued: true, objectIds: [] }, and the reset follows once the colours already chosen are read.
Pick a colour from a rule or a button
{ "type": "pluginAction", "pluginId": "mp4e:colourways", "actionId": "select",
  "config": { "lookId": "look01", "colourway": "sage" } }

Events and variables

PropTypeDefaultDescription
colourChosen{ lookId, objectIds, colourway, name, hex }-A colour was chosen by the viewer, by select or by reset. Original is colourway "original" with name "Original" and an empty hex. Nothing is emitted for a choice that changes nothing.
lookShown{ lookId }-Another look came on stage and the selector now shows it.

Rules hear them as plugin:mp4e:colourways:<event>; your page hears them through onEvent:

Track colour choices
<MP4EPlayer
  src="/runway.mp4"
  onEvent={(event, data) => {
    if (event === 'plugin:emit' && data.event === 'colourChosen') {
      // { lookId, objectIds, colourway, name, hex }
      analytics.track('colour_chosen', data.data);
    }
  }}
/>

Installing Colourways creates two variables, which it keeps current. Read them; leave the writing to Colourways.

  • mp4e:colourways:state — the viewer's choices: { <objectId>: { look, colourway, name, hex } }. A garment in its original colour has no entry, so {{mp4e:colourways:state.obj_2.hex}} is empty.
  • mp4e:colourways:catalog — the looks as Colourways read them, by look and by garment.