Skip to content

🎥 Make videos programmatically with React

2.6 KB
Raw Blame
import {loadFont} from '@remotion/fonts';
import {
	AbsoluteFill,
	interpolate,
	Sequence,
	staticFile,
	useCurrentFrame,
	Easing,
} from 'remotion';
import {ApplicationRenderButton} from './Applications/RenderButton';
import {ApplicationSimpleApp} from './Applications/SimpleApp';
import {ApplicationVideoEditor} from './Applications/VideoEditor';

loadFont({
	family: 'GT Planar',
	url: staticFile('GT Planar/GT-Planar-Medium.woff2'),
	weight: '500',
});

loadFont({
	family: 'GT Planar',
	url: staticFile('GT Planar/GT-Planar-Bold.woff2'),
	weight: '700',
});

export function Applications() {
	const frame = useCurrentFrame();

	return (
		<AbsoluteFill>
			<Sequence
				durationInFrames={180}
				name="Simple application slide"
				style={{
					translate: interpolate(
						frame,
						[0, 85, 95, 167, 179],
						['0px 0px', '0px 0px', '-1240px 0px', '-1240px 0px', '0px 0px'],
						{
							extrapolateLeft: 'clamp',
							extrapolateRight: 'clamp',
							easing: [
								Easing.linear,
								Easing.spring({
									damping: 200,
									mass: 1,
									stiffness: 100,
									allowTail: true,
									durationRestThreshold: 0.02,
									overshootClamping: false,
								}),
								Easing.linear,
								Easing.spring({
									damping: 200,
									mass: 1,
									stiffness: 100,
									allowTail: true,
									durationRestThreshold: 0.02,
									overshootClamping: false,
								}),
							],
						},
					),
				}}
			>
				<ApplicationSimpleApp
					kineticTypeColor="#000000"
					kineticTypeFrame={frame >= 167 ? 0 : frame}
					kineticTypeSpeed={1.5}
				/>
			</Sequence>
			<Sequence
				durationInFrames={180}
				name="Video editor slide"
				style={{
					translate: interpolate(
						frame,
						[0, 85, 95, 167, 179],
						['1240px 0px', '1240px 0px', '0px 0px', '0px 0px', '1240px 0px'],
						{
							extrapolateLeft: 'clamp',
							extrapolateRight: 'clamp',
							easing: [
								Easing.linear,
								Easing.spring({
									damping: 200,
									mass: 1,
									stiffness: 100,
									allowTail: true,
									durationRestThreshold: 0.02,
									overshootClamping: false,
								}),
								Easing.linear,
								Easing.spring({
									damping: 200,
									mass: 1,
									stiffness: 100,
									allowTail: true,
									durationRestThreshold: 0.02,
									overshootClamping: false,
								}),
							],
						},
					),
				}}
			>
				<ApplicationVideoEditor kineticTypeFrame={frame - 95} />
			</Sequence>
			<Sequence>
				<ApplicationRenderButton />
			</Sequence>
		</AbsoluteFill>
	);
}

export {ApplicationRenderButton, ApplicationSimpleApp, ApplicationVideoEditor};