🎥 Make videos programmatically with React
import type {InterpolateOutputOption} from './interpolate.js';
export type HiddenFieldSchema = {
type: 'hidden';
keyframable?: boolean;
};
export type NumberFieldSchema = {
type: 'number';
min?: number;
max?: number;
step?: number;
integer?: boolean;
default: number | null | undefined;
description?: string;
hiddenFromList: boolean;
keyframable?: boolean;
defaultKeyframeOutput?: InterpolateOutputOption;
};
export type BooleanFieldSchema = {
type: 'boolean';
default: boolean;
description?: string;
keyframable?: boolean;
};
export type RotationCssFieldSchema = {
type: 'rotation-css';
step?: number;
default: string | undefined;
description?: string;
keyframable?: boolean;
};
export type RotationDegreesFieldSchema = {
type: 'rotation-degrees';
min?: number;
max?: number;
step?: number;
default: number | undefined;
description?: string;
keyframable?: boolean;
};
export type TranslateFieldSchema = {
type: 'translate';
step?: number;
default: string | undefined;
description?: string;
keyframable?: boolean;
};
export type TransformOriginFieldSchema = {
type: 'transform-origin';
step?: number;
default: string | undefined;
description?: string;
keyframable?: boolean;
};
export type ScaleFieldSchema = {
type: 'scale';
min?: number;
max?: number;
step?: number;
default: number | string | undefined;
description?: string;
keyframable?: boolean;
defaultKeyframeOutput?: InterpolateOutputOption;
};
export type UvCoordinateFieldSchema = {
type: 'uv-coordinate';
min?: number;
max?: number;
step?: number;
visual?:
| {
readonly type: 'line';
readonly to: string;
}
| {
readonly type: 'ellipse';
readonly width: string;
readonly height: string;
readonly rotation?: string;
readonly innerScale?: string;
};
default: readonly [number, number] | undefined;
description?: string;
keyframable?: boolean;
};
export type ColorFieldSchema = {
type: 'color';
default: string | undefined;
description?: string;
keyframable?: boolean;
};
export type StringFieldSchema = {
type: 'string';
default: string;
description?: string;
keyframable?: false;
};
/** @deprecated Use StringFieldSchema with type: 'string' instead. */
export type TextContentFieldSchema = Omit<StringFieldSchema, 'type'> & {
/** @deprecated Use 'string' instead. */
type: 'text-content';
};
export type SvgPathFieldSchema = {
type: 'svg-path';
default: string | undefined;
description?: string;
keyframable?: boolean;
};
export type FontFamilyFieldSchema = {
type: 'font-family';
default: string | undefined;
description?: string;
keyframable?: false;
};
export type FontWeightFieldSchema = {
type: 'font-weight';
default: number | string | undefined;
description?: string;
keyframable?: boolean;
};
export type AssetFieldSchema = {
type: 'asset';
assetType?: 'audio' | 'video' | 'image';
default: string | undefined;
description?: string;
keyframable?: false;
};
export type EnumFieldSchema = {
type: 'enum';
default: string;
description?: string;
variants: Record<string, InteractivitySchema>;
keyframable?: boolean;
};
export type NumberArrayItemSchema = Omit<
NumberFieldSchema,
| 'default'
| 'description'
| 'hiddenFromList'
| 'keyframable'
| 'defaultKeyframeOutput'
>;
export type BooleanArrayItemSchema = Omit<
BooleanFieldSchema,
'default' | 'description' | 'keyframable'
>;
export type RotationCssArrayItemSchema = Omit<
RotationCssFieldSchema,
'default' | 'description' | 'keyframable'
>;
export type RotationDegreesArrayItemSchema = Omit<
RotationDegreesFieldSchema,
'default' | 'description' | 'keyframable'
>;
export type TranslateArrayItemSchema = Omit<
TranslateFieldSchema,
'default' | 'description' | 'keyframable'
>;
export type UvCoordinateArrayItemSchema = Omit<
UvCoordinateFieldSchema,
'default' | 'description' | 'keyframable'
>;
export type ColorArrayItemSchema = Omit<
ColorFieldSchema,
'default' | 'description' | 'keyframable'
>;
export type EnumArrayItemSchema = {
type: 'enum';
variants: readonly string[];
};
export type ArrayItemFieldSchema =
| NumberArrayItemSchema
| BooleanArrayItemSchema
| RotationCssArrayItemSchema
| RotationDegreesArrayItemSchema
| TranslateArrayItemSchema
| UvCoordinateArrayItemSchema
| ColorArrayItemSchema
| EnumArrayItemSchema;
export type ArrayFieldSchema = {
type: 'array';
item: ArrayItemFieldSchema;
default: readonly unknown[] | undefined;
minLength?: number;
maxLength?: number;
newItemDefault: unknown;
description?: string;
keyframable?: false;
};
export type CaptionsFieldSchema = {
type: 'remotion-captions';
default: readonly unknown[] | undefined;
description?: string;
keyframable: false;
};
export type VisibleFieldSchema =
| NumberFieldSchema
| BooleanFieldSchema
| RotationCssFieldSchema
| RotationDegreesFieldSchema
| TranslateFieldSchema
| TransformOriginFieldSchema
| ScaleFieldSchema
| UvCoordinateFieldSchema
| ColorFieldSchema
| StringFieldSchema
| TextContentFieldSchema
| SvgPathFieldSchema
| FontFamilyFieldSchema
| FontWeightFieldSchema
| AssetFieldSchema
| ArrayFieldSchema
| CaptionsFieldSchema
| EnumFieldSchema;
export type InteractivitySchemaField = VisibleFieldSchema | HiddenFieldSchema;
export type InteractivitySchema = {[key: string]: InteractivitySchemaField};
export const captionsSchema = {
captions: {
type: 'remotion-captions',
default: undefined,
description: 'Captions',
keyframable: false,
},
} as const satisfies InteractivitySchema;
export type InteractivitySchemaKeysRecord<S extends InteractivitySchema> =
Record<keyof S, unknown>;
export const transformSchema = {
'style.transformOrigin': {
type: 'transform-origin',
step: 1,
default: '50% 50%',
description: 'Transform origin',
},
'style.translate': {
type: 'translate',
step: 1,
default: '0px 0px',
description: 'Offset',
},
'style.scale': {
type: 'scale',
max: 100,
step: 0.01,
default: 1,
description: 'Scale',
defaultKeyframeOutput: 'perceptual-scale',
},
'style.rotate': {
type: 'rotation-css',
step: 1,
default: '0deg',
description: 'Rotation',
},
'style.opacity': {
type: 'number',
min: 0,
max: 1,
step: 0.01,
default: 1,
description: 'Opacity',
hiddenFromList: false,
},
} as const satisfies InteractivitySchema;
export const sequenceVisualStyleSchema = transformSchema;
export const textSchema = {
'style.color': {
type: 'color',
default: undefined,
description: 'Color',
},
'style.fontFamily': {
type: 'font-family',
default: undefined,
description: 'Font family',
keyframable: false,
},
'style.fontSize': {
type: 'number',
default: undefined,
min: 0,
step: 1,
description: 'Font size',
hiddenFromList: false,
},
'style.lineHeight': {
type: 'number',
default: undefined,
min: 0,
step: 0.05,
description: 'Line height',
hiddenFromList: false,
},
'style.fontWeight': {
type: 'font-weight',
default: 400,
description: 'Font weight',
},
'style.fontStyle': {
type: 'enum',
default: 'normal',
description: 'Font style',
variants: {
normal: {},
italic: {},
oblique: {},
},
},
'style.textAlign': {
type: 'enum',
default: 'left',
description: 'Text align',
variants: {
left: {},
center: {},
right: {},
justify: {},
start: {},
end: {},
},
},
'style.letterSpacing': {
type: 'number',
default: undefined,
step: 0.1,
description: 'Letter spacing',
hiddenFromList: false,
},
} as const satisfies InteractivitySchema;
export const borderSchema = {
'style.borderWidth': {
type: 'number',
default: undefined,
min: 0,
step: 1,
description: 'Border width',
hiddenFromList: false,
},
'style.borderStyle': {
type: 'enum',
// `none` is the CSS initial value of border-style.
default: 'none',
description: 'Border style',
variants: {
none: {},
hidden: {},
solid: {},
dashed: {},
dotted: {},
double: {},
groove: {},
ridge: {},
inset: {},
outset: {},
},
},
'style.borderColor': {
type: 'color',
default: undefined,
description: 'Border color',
},
} as const satisfies InteractivitySchema;
export const borderRadiusSchema = {
'style.borderRadius': {
type: 'number',
default: 0,
min: 0,
step: 1,
description: 'Border radius',
hiddenFromList: false,
keyframable: true,
},
'style.borderTopLeftRadius': {
type: 'number',
default: 0,
min: 0,
step: 1,
description: 'Top left radius',
hiddenFromList: false,
},
'style.borderTopRightRadius': {
type: 'number',
default: 0,
min: 0,
step: 1,
description: 'Top right radius',
hiddenFromList: false,
},
'style.borderBottomRightRadius': {
type: 'number',
default: 0,
min: 0,
step: 1,
description: 'Bottom right radius',
hiddenFromList: false,
},
'style.borderBottomLeftRadius': {
type: 'number',
default: 0,
min: 0,
step: 1,
description: 'Bottom left radius',
hiddenFromList: false,
},
} as const satisfies InteractivitySchema;
export const backgroundSchema = {
'style.backgroundColor': {
type: 'color',
// `transparent` is the CSS initial value of background-color.
default: 'transparent',
description: 'Color',
},
} as const satisfies InteractivitySchema;
const svgColorSchema = {
color: {
type: 'color',
default: undefined,
description: 'Current color',
},
} as const satisfies InteractivitySchema;
export const svgStrokeSchema = {
...svgColorSchema,
stroke: {
type: 'color',
// `none` is the SVG initial value of stroke.
default: 'none',
description: 'Stroke',
},
strokeWidth: {
type: 'number',
// `1` is the SVG initial value of stroke-width.
default: 1,
description: 'Stroke width',
min: 0,
step: 1,
hiddenFromList: false,
},
} as const satisfies InteractivitySchema;
export const svgPaintSchema = {
fill: {
type: 'color',
default: undefined,
description: 'Fill',
},
...svgStrokeSchema,
} as const satisfies InteractivitySchema;
/**
* Controls for children content. Currently uses a string field, but the field
* type may evolve to support richer content.
*/
export const childrenSchema: {children: InteractivitySchemaField} = {
children: {
type: 'string',
default: '',
description: 'Text',
keyframable: false,
},
};
/** @deprecated Use childrenSchema instead. */
export const textContentSchema = childrenSchema;
export const premountSchema = {
premountFor: {
type: 'number',
// Omission inherits the preview's default; zero explicitly disables it.
default: undefined,
description: 'Premount For',
min: 0,
step: 1,
hiddenFromList: false,
keyframable: false,
},
postmountFor: {
type: 'number',
default: 0,
min: 0,
step: 1,
hiddenFromList: true,
keyframable: false,
},
} as const satisfies InteractivitySchema;
export const sequencePremountSchema = {
...premountSchema,
} as const satisfies InteractivitySchema;
export const cropSchema = {
cropLeft: {
type: 'number',
default: 0,
description: 'Crop left',
min: 0,
max: 1,
step: 0.01,
hiddenFromList: false,
keyframable: true,
},
cropRight: {
type: 'number',
default: 0,
description: 'Crop right',
min: 0,
max: 1,
step: 0.01,
hiddenFromList: false,
keyframable: true,
},
cropTop: {
type: 'number',
default: 0,
description: 'Crop top',
min: 0,
max: 1,
step: 0.01,
hiddenFromList: false,
keyframable: true,
},
cropBottom: {
type: 'number',
default: 0,
description: 'Crop bottom',
min: 0,
max: 1,
step: 0.01,
hiddenFromList: false,
keyframable: true,
},
} as const satisfies InteractivitySchema;
export const sequenceCropSchema = cropSchema;
export const sequenceStyleSchema = {
...sequenceCropSchema,
...transformSchema,
...backgroundSchema,
...borderSchema,
...borderRadiusSchema,
...sequencePremountSchema,
} as const satisfies InteractivitySchema;
export const hiddenField: InteractivitySchemaField = {
type: 'boolean',
default: false,
description: 'Hidden',
};
const showInTimelineField: InteractivitySchemaField = {
type: 'hidden',
};
export const sequenceNameField: InteractivitySchemaField = {
type: 'hidden',
};
export const extendSchemaWithSequenceName = <S extends InteractivitySchema>(
schema: S,
): S & {name: InteractivitySchemaField} => {
return {
name: sequenceNameField,
...schema,
};
};
export const durationInFramesField = {
type: 'number',
default: undefined,
min: 1,
step: 1,
hiddenFromList: true,
} as const satisfies InteractivitySchemaField;
export const fromField = {
type: 'number',
default: 0,
step: 1,
hiddenFromList: true,
} as const satisfies InteractivitySchemaField;
export const trimBeforeField = {
type: 'number',
default: 0,
min: 0,
step: 1,
hiddenFromList: true,
} as const satisfies InteractivitySchemaField;
// Packed timeline containers expose timing through the inspector.
export const sequenceTimingSchema = {
from: {
...fromField,
description: 'From',
hiddenFromList: false,
keyframable: false,
},
durationInFrames: {
...durationInFramesField,
description: 'Duration',
hiddenFromList: false,
keyframable: false,
},
trimBefore: {
...trimBeforeField,
description: 'Trim before',
hiddenFromList: false,
keyframable: false,
},
} as const satisfies InteractivitySchema;
export const trimAfterField = {
type: 'number',
default: undefined,
min: 1,
step: 1,
hiddenFromList: true,
} as const satisfies InteractivitySchemaField;
export const loopField = {
type: 'boolean',
default: false,
description: 'Loop',
keyframable: false,
} as const satisfies InteractivitySchemaField;
export const freezeField = {
type: 'number',
default: null,
step: 1,
hiddenFromList: true,
} as const satisfies InteractivitySchemaField;
const playbackRateField = {
type: 'number',
default: 1,
min: 0.01,
step: 0.1,
description: 'Playback rate',
hiddenFromList: false,
keyframable: false,
} as const satisfies InteractivitySchemaField;
export const baseSchema = {
durationInFrames: durationInFramesField,
from: fromField,
trimBefore: trimBeforeField,
playbackRate: playbackRateField,
freeze: freezeField,
hidden: hiddenField,
name: sequenceNameField,
showInTimeline: showInTimelineField,
} as const satisfies InteractivitySchema;
// For static images: speed does not change what they show.
export const baseSchemaWithoutPlaybackRate = {
durationInFrames: durationInFramesField,
from: fromField,
trimBefore: trimBeforeField,
freeze: freezeField,
hidden: hiddenField,
name: sequenceNameField,
showInTimeline: showInTimelineField,
} as const satisfies InteractivitySchema;
export const sequenceSchema = {
...baseSchema,
layout: {
type: 'enum',
default: 'absolute-fill',
description: 'Layout',
variants: {
'absolute-fill': sequenceStyleSchema,
none: {},
},
},
} as const satisfies InteractivitySchema;
export const baseSchemaWithoutFrom = {
durationInFrames: durationInFramesField,
trimBefore: trimBeforeField,
playbackRate: playbackRateField,
freeze: freezeField,
hidden: hiddenField,
name: sequenceNameField,
showInTimeline: showInTimelineField,
} as const satisfies InteractivitySchema;
export const sequenceSchemaWithoutFrom = {
...baseSchemaWithoutFrom,
layout: sequenceSchema.layout,
} as const satisfies InteractivitySchema;
export const sequenceSchemaDefaultLayoutNone: InteractivitySchema = {
...sequenceSchema,
layout: {
...sequenceSchema.layout,
default: 'none',
},
};