Host Overrides

Inject layers, plugins, variables, and settings into any video at runtime without modifying the .mp4 file.

Overview

The overrides prop lets a host application deep-merge partial metadata into any MP4E video at runtime. The original .mp4 file is never modified — the engine merges your overrides into the document in memory when it loads it, and runs the merged result.

This keeps videos fully portable. The same video file plays identically on any host, while each host can layer its own branding, analytics, variables, restrictions, and rules on top.

Works on any video
Neither metadata nor overrides requires the source file to carry MP4E metadata at all. An ordinary .mp4 with no embedded atom still gets the full interactive engine — the player generates a minimal base document from the video’s own dimensions and duration, and overrides merges on top of that exactly the same way it merges on top of an authored file. This is what makes it possible to make any video interactive purely from the host side.
Non-destructive
Overrides are additive. They never strip content from the base metadata — they only add new content or replace specific fields. The video creator’s original work is always preserved.
Frame-accurate content on an unauthored video
Fixed overlays, watermarks, and time-based content (like the promo timer below) don’t need exact frame rate information. But if an override defines rules or overlays that must land on an exact frame of a video with no authored metadata, supply your own metadata containing the correct videoDetails.fps — the generated base for an unauthored video defaults fps to 30, which may not match the source.

How It Works

Whatever the base document is — host-provided, extracted from the MP4 atom, or generated when the video carries no embedded metadata — the engine merges your overrides into it using a deep-merge algorithm and runs the merged document. The base itself is kept unchanged, so a new overrides value is always merged onto the original base, never onto a previous result. The merge rules are:

Data ShapeMerge Behavior
Record objectsDeep-merged recursively. Override keys win; base-only keys are preserved.
Arrays of { id } objectsMatched by id. If an override item has the same ID as a base item, the two are deep-merged. New IDs, and items without an id, are appended to the end.
layers (special case)ID-match merge with cascade: the overlays array within each matched layer is also ID-merged (any nested array of id’d items inside a matched item merges the same way).
Plain arrays (no id)Override replaces entirely.
Primitives, type mismatches, nullOverride replaces entirely. An explicit null is a value, not a deletion.

The following example shows a full merge from base metadata through overrides to the final result:

Deep-merge walkthrough
1// Original metadata (embedded in the .mp4 file)
2{
3 settings: {
4 restrictions: { navigate: true, download: true }
5 },
6 layers: [
7 {
8 id: 'layer-1',
9 name: 'Products',
10 overlays: [
11 { id: 'overlay-a', type: 'core:button', config: { text: 'Buy' } }
12 ]
13 }
14 ],
15 variables: [
16 { id: 'score', name: 'Score', type: 'number', default: 0 }
17 ]
18}
19
20// Overrides (provided by host at runtime)
21{
22 settings: {
23 restrictions: { navigate: false }
24 },
25 layers: [
26 {
27 id: 'layer-1',
28 overlays: [
29 { id: 'overlay-a', config: { text: 'Purchase Now' } }
30 ]
31 },
32 {
33 id: '__host_brand__',
34 name: 'Branding',
35 overlays: [{ id: 'logo', type: 'core:image', config: { src: '/logo.png' } }]
36 }
37 ],
38 variables: [
39 { id: 'userName', name: 'User name', type: 'text', default: 'Alice' }
40 ]
41}
42
43// Result after merge
44{
45 settings: {
46 restrictions: { navigate: false, download: true } // deep-merged: navigate overridden
47 },
48 layers: [
49 {
50 id: 'layer-1',
51 name: 'Products', // preserved from base
52 overlays: [
53 { id: 'overlay-a', type: 'core:button', config: { text: 'Purchase Now' } }
54 // ^ ID-matched, config overridden
55 ]
56 },
57 {
58 id: '__host_brand__', // new layer appended
59 name: 'Branding',
60 overlays: [{ id: 'logo', type: 'core:image', config: { src: '/logo.png' } }]
61 }
62 ],
63 variables: [
64 { id: 'score', name: 'Score', type: 'number', default: 0 }, // preserved from base
65 { id: 'userName', name: 'User name', type: 'text', default: 'Alice' } // new id appended
66 ]
67}

Updating Overrides at Runtime

Re-render <MP4EPlayer> with a new overrides value at any point — during playback, in response to a state change, on a timer — and the player picks it up without reconstructing the engine or reloading the video source.

Each new overrides value replaces the previous one outright; it is not merged into whatever was showing a moment ago. Passing {}, null, or undefined clears the override layer entirely, restoring metadata (or the generated base, if none was provided) unchanged. A parent re-render that produces a new object with identical content is a no-op — only an actual content change triggers an update. overrides must be an object: anything else (an array, a string, a number) is ignored, with the console warning [MP4E] overrides must be an object, and the video plays as if no overrides were given.

Playback and viewer state carry through
Changing overrides live doesn’t reset the video. Playback position, paused state, variable values, running timers, counters, the current scene, and any layers the viewer has toggled at runtime all carry through the swap when the same ids still exist in the new effective document — only content that actually changed (a new/removed layer, overlay, or variable, or a variable whose type changed) updates. A viewer mid-video with items in a cart or progress through a quiz keeps that state while you push a new promo banner, swap in updated pricing, or toggle a restriction. On a file that streams its object tracking, the tracking already loaded is kept as well — an overrides change fetches none of it again. Media you inject under media (an item’s fallbackUrl) resolves the same way whether it is given at load or in a later overrides value, and a changed fallbackUrl loads the new URL.
Toggling a promo overlay at runtime
1function VideoWithPromo({ videoUrl, promoActive }) {
2 return (
3 <MP4EPlayer
4 src={videoUrl}
5 // Re-rendering with a new overrides value REPLACES the current
6 // override layer outright — it does not merge into whatever was
7 // showing before. The base video (or generated base, if there's no
8 // authored metadata) is untouched either way.
9 overrides={
10 promoActive
11 ? {
12 layers: [{
13 id: '__host_promo__',
14 name: 'Promo',
15 order: 1000, // explicit — see "Host-Injected Layers" below
16 overlays: [{
17 id: 'promo-banner',
18 type: 'core:banner',
19 zIndex: 1000,
20 config: { text: '20% off today only' },
21 }],
22 }],
23 }
24 : undefined // clears the override layer, restoring the base
25 }
26 />
27 );
28}

Both <MP4EPlayer overrides={...}> and the imperative playerRef.current?.reloadMetadata() method (see Methods Reference) apply the new document asynchronously — already-mounted plugins are refreshed with freshly re-interpolated content once the swap lands, with no visible flash or DOM teardown.

To check what the engine is running, call playerRef.current?.getEffectiveMetadata(): it returns the view of the merged document — layers, overlays and their render fields, video details and counts — not the full document. Variable values are read with getVariable().

Override Structure

The overrides prop mirrors the MP4E metadata structure exactly. Any top-level metadata field can be overridden: layers, plugins, variables, settings, projectSettings, scenes, and more.

Full overrides example
1<MP4EPlayer
2 src="/video.mp4"
3 overrides={{
4 layers: [{
5 id: '__host_branding__',
6 name: 'Host Branding',
7 overlays: [{
8 id: 'watermark',
9 type: 'core:image',
10 position: {
11 x: 90, y: 5,
12 width: 8, height: 8,
13 xUnit: '%', yUnit: '%',
14 widthUnit: '%', heightUnit: '%'
15 },
16 config: { src: 'https://myapp.com/logo.png' }
17 }]
18 }],
19 plugins: {
20 'host-analytics': {
21 id: 'host-analytics',
22 type: 'mp4e:analytics',
23 source: 'external',
24 config: { trackingId: 'UA-XXXXX' }
25 }
26 },
27 variables: [
28 { id: 'hostApiKey', name: 'Host API key', type: 'text', default: 'sk_live_xxx' },
29 { id: 'userName', name: 'User name', type: 'text', default: 'John' }
30 ],
31 settings: {
32 restrictions: { navigate: false, download: false }
33 }
34 }}
35/>

Common Use Cases

Branding Watermark

Add a persistent logo overlay to every video on your platform without editing each file.

Watermark layer
1// Add a watermark logo to every video
2<MP4EPlayer
3 src={videoUrl}
4 overrides={{
5 layers: [{
6 id: '__host_watermark__',
7 name: 'Watermark',
8 overlays: [{
9 id: 'logo',
10 type: 'core:image',
11 position: {
12 x: 92, y: 4,
13 width: 6, height: 6,
14 xUnit: '%', yUnit: '%',
15 widthUnit: '%', heightUnit: '%'
16 },
17 config: {
18 src: 'https://myapp.com/assets/logo-white.png',
19 opacity: 0.7
20 }
21 }]
22 }]
23 }}
24/>

Analytics Service Plugin

Inject a service plugin that tracks viewer interactions and reports them to your analytics backend.

Analytics plugin
1// Inject an analytics service plugin
2<MP4EPlayer
3 src={videoUrl}
4 overrides={{
5 plugins: {
6 'host-analytics': {
7 id: 'host-analytics',
8 type: 'mp4e:analytics',
9 source: 'external',
10 config: {
11 trackingId: 'UA-XXXXX',
12 endpoint: 'https://myapp.com/api/analytics'
13 }
14 }
15 }
16 }}
17/>

Override Restrictions

Enforce sequential playback or disable downloads for content that requires it, regardless of what the video creator originally configured.

Restrictions
1// Disable seeking and downloading for paid content
2<MP4EPlayer
3 src={videoUrl}
4 overrides={{
5 settings: {
6 restrictions: {
7 navigate: false, // Disable seeking (sequential viewing only)
8 download: false // Remove download option
9 }
10 }
11 }}
12/>

Inject Host-Specific Variables

Provide runtime variables that plugins can reference via {{variableName}} interpolation. This is how hosts pass user context, API keys, and locale data into videos. The document’s variables is an array of { id, name, type, default }, so overrides follow the same id-matched merge as layers: a new id adds a variable, and an id the video already defines updates that variable. Do not pass variables as an object keyed by id — an object replaces the video’s whole variable list and defines no variable.

Host variables
1// Inject host-specific variables that plugins can reference
2<MP4EPlayer
3 src={videoUrl}
4 overrides={{
5 variables: [
6 { id: 'userName', name: 'User name', type: 'text', default: currentUser.name },
7 { id: 'userTier', name: 'User tier', type: 'text', default: currentUser.tier },
8 { id: 'apiBaseUrl', name: 'API base URL', type: 'text', default: 'https://myapp.com/api' },
9 { id: 'currency', name: 'Currency', type: 'text', default: userLocale.currency }
10 ]
11 }}
12/>

Content Softness for a Live Creative

A replacement zone with Match the footage on softens what it draws only by the difference between the footage's softness and the content's own. Images and videos from the project's media library carry their own softness, so the player knows it whichever one the zone shows; a creative from a web address — an ad server's image — does not, and is treated as a perfectly sharp image. When you know a creative is softer, set the zone's lookContentBlur (the edge width in video pixels as the creative is drawn in the zone, 0–8) through overrides, or set the variable the zone's Content softness reads. A value set this way wins over the content's own softness for the zone's image or video.

Content softness for a live creative
1// A zone that matches the footage draws your live creative (an http image the file
2// never carried): tell it how soft the creative is, as the player draws it in the zone.
3<MP4EPlayer
4 src={videoUrl}
5 overrides={{
6 layers: [{
7 id: 'layer_billboard', // the creator's layer and zone ids (id-matched merge)
8 overlays: [{
9 id: 'billboard-zone',
10 config: {
11 src: creative.url,
12 lookContentBlur: creative.softness // px; omit it to use the default for a sharp image
13 }
14 }]
15 }]
16 }}
17/>
18
19// Or, when the zone's Content softness is a {{variable}} (e.g. {{creativeSoftness}}),
20// set the variable as each creative arrives:
21playerRef.current?.setVariable('creativeSoftness', 1.4);

Host-Controlled Rules

Add event handlers that fire on scene transitions, overlay clicks, or any engine event. The host can wire up its own analytics, navigation, or business logic.

Event rules
1// Add host-controlled event handlers
2<MP4EPlayer
3 src={videoUrl}
4 overrides={{
5 projectSettings: {
6 eventRules: {
7 'scene:enter': [{
8 type: 'pluginAction',
9 pluginId: 'host-analytics',
10 actionId: 'trackEvent',
11 config: { event: 'scene_view' }
12 }]
13 }
14 }
15 }}
16/>

Overrides vs Config

Two complementary props
Overrides and config serve different purposes and work together:
  • overrides injects content (additive) — adds layers, plugins, variables, settings into the document the engine runs.
  • config restricts behavior (subtractive) — disables actions, sandboxes plugins, gates dangerous operations, and limits what the engine can do at runtime.

Use overrides to put content in. Use config to keep behavior out. They are complementary, not interchangeable.

Host-Injected Layers

Layers added via overrides are appended after the video creator’s layers, but appending alone does not make them render on top. Stacking is controlled by each layer’s order and each overlay’s zIndex, exactly like creator content. A host layer that needs to sit above everything else must set an explicit order/zIndex higher than the creator’s content — there is no implicit host-priority tier.

By convention, prefix host layer and overlay IDs with __host__ to avoid collisions with creator-defined IDs. This also makes it easy to identify host-injected content when debugging.

Host layer conventions — explicit order/zIndex for topmost rendering
1// Convention: prefix host layer IDs with __host__.
2// order/zIndex are set explicitly here so this content renders ABOVE the
3// creator's layers — appending alone would not guarantee that.
4<MP4EPlayer
5 src={videoUrl}
6 overrides={{
7 layers: [
8 {
9 id: '__host_branding__',
10 name: 'Host Branding',
11 order: 1000,
12 overlays: [{
13 id: '__host_logo__',
14 type: 'core:image',
15 zIndex: 1000,
16 position: { x: 90, y: 5, width: 8, height: 8,
17 xUnit: '%', yUnit: '%', widthUnit: '%', heightUnit: '%' },
18 config: { src: '/logo.png' }
19 }]
20 },
21 {
22 id: '__host_cta__',
23 name: 'Host Call-to-Action',
24 order: 1001,
25 overlays: [{
26 id: '__host_signup_btn__',
27 type: 'core:button',
28 zIndex: 1001,
29 position: { x: 50, y: 90, width: 20, height: 6,
30 xUnit: '%', yUnit: '%', widthUnit: '%', heightUnit: '%' },
31 config: { text: 'Sign Up Free' }
32 }]
33 }
34 ]
35 }}
36/>
Stacking is explicit, not implicit
Host layers do not receive implicit visual priority. Set order on the layer and zIndex on its overlays whenever a host override needs to render above (or below) the creator’s content.
ID-match behavior
If a host override layer has the same id as a creator layer, the two will be deep-merged (including their overlays). Use the __host__ prefix to ensure host layers are always separate from creator content.

Swap the Controls

A host can replace the controls a video carries without touching the file: inject a controls plugin through overrides.plugins and name it in the pluginOverrides prop. The official Controls plugin works this way on any video, including files exported with older controls.

Swap in the Controls plugin
1// Put the official Controls plugin on any video, even one exported without it
2const row = await (await fetch('https://api.mp4e.com/api/plugins/slug/mp4e-controls')).json();
3const controlsEntry = {
4 id: `${row.namespace}:${row.identifier}`, // 'mp4e:controls'
5 name: row.name, type: row.type, category: row.category, version: row.version,
6 content: row.content, configSchema: row.configSchema, defaultConfig: row.defaultConfig,
7 sizing: row.sizing, source: 'marketplace',
8 namespace: row.namespace, identifier: row.identifier,
9 signature: { signer: row.signatureSigner, value: row.signatureValue },
10};
11
12<MP4EPlayer
13 key={useControls ? 'controls' : 'own'} // pluginOverrides is read when the player is created
14 src={videoUrl}
15 overrides={{ plugins: { 'mp4e:controls': controlsEntry } }}
16 pluginOverrides={{ controls: { pluginId: 'mp4e:controls' } }}
17/>
Chosen when the player is created
pluginOverrides is read when the player is created, unlike overrides, which can change live. A host that decides later must remount the player (change its React key).

To switch live instead, set the video's own choice through overrides: player: { controls: { pluginId: 'mp4e:controls' } } next to the plugin in overrides.plugins, or player: { controls: { enabled: false } } for no controls at all. pluginOverrides.controls, when given, wins over both.