🎥 Make videos programmatically with React
rich timeline stuff
Jonny Burgerd8f5814bc6c2
diff --git a/packages/cli/src/editor/components/CurrentComposition.tsx b/packages/cli/src/editor/components/CurrentComposition.tsxindex f07e5e7a85..d7156938a2 100644--- a/packages/cli/src/editor/components/CurrentComposition.tsx+++ b/packages/cli/src/editor/components/CurrentComposition.tsx@@ -1,7 +1,8 @@-import React from 'react';+import React, {useContext} from 'react';import {Internals} from 'remotion';import styled from 'styled-components';import {renderFrame} from '../state/render-frame';+import {RichTimelineContext} from '../state/rich-timeline';import {Thumbnail} from './Thumbnail';const Container = styled.div`@@ -38,6 +39,7 @@ const targetHeight = 60;const targetWidth = (targetHeight * 16) / 9;export const CurrentComposition = () => {+ const richTimelineContext = useContext(RichTimelineContext);const video = Internals.useVideo();if (!video) {return <Container />;@@ -47,7 +49,7 @@ export const CurrentComposition = () => {return (<Container><Row>- {Internals.FEATURE_FLAG_RICH_PREVIEWS ? (+ {richTimelineContext.richTimeline ? (<><Thumbnailcomposition={video}diff --git a/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx b/packages/cli/src/editor/components/Timeline/TimelineSequence.tsxindex a3cfe328d4..d0ef0024e8 100644--- a/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx+++ b/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx@@ -1,4 +1,4 @@-import React, {useMemo, useState} from 'react';+import React, {useContext, useMemo, useState} from 'react';import {Internals, TSequence} from 'remotion';import {getTimelineSequenceLayout,@@ -6,6 +6,7 @@ import {} from '../../helpers/get-timeline-sequence-layout';import {TIMELINE_LAYER_HEIGHT} from '../../helpers/timeline-layout';import {useElementSize} from '../../hooks/get-el-size';+import {RichTimelineContext} from '../../state/rich-timeline';import {AudioWaveform} from '../AudioWaveform';import {Thumbnail} from '../Thumbnail';import {sliderAreaRef} from './timeline-refs';@@ -18,6 +19,7 @@ export const TimelineSequence: React.FC<{fps: number;}> = ({s, fps}) => {const size = useElementSize(sliderAreaRef);+ const {richTimeline} = useContext(RichTimelineContext);const windowWidth = size?.width ?? 0;// If a duration is 1, it is essentially a still and it should have width 0@@ -65,16 +67,17 @@ export const TimelineSequence: React.FC<{const thumbnailWidth = TIMELINE_LAYER_HEIGHT * (video.width / video.height);- const thumbnailFit = !Internals.FEATURE_FLAG_RICH_PREVIEWS ? 0 : 1;+ const thumbnailsToShow = richTimeline ? 1 : 0;return (<div key={s.id} style={style} title={s.displayName}><div style={row}>{s.type === 'sequence' &&- new Array(thumbnailFit).fill(true).map((_, i) => {- const frameToDisplay = Internals.FEATURE_FLAG_RICH_PREVIEWS- ? Math.floor((i / thumbnailFit) * video.durationInFrames)- : s.from;+ new Array(thumbnailsToShow).fill(true).map((_, i) => {+ const frameToDisplay = Math.floor(+ (i / thumbnailsToShow) * video.durationInFrames+ );+return (<Thumbnailkey={frameToDisplay}diff --git a/packages/core/src/feature-flags.ts b/packages/core/src/feature-flags.tsindex 4bf8c214d0..3c5c78555b 100644--- a/packages/core/src/feature-flags.ts+++ b/packages/core/src/feature-flags.ts@@ -8,6 +8,3 @@ export const FEATURE_FLAG_FIREFOX_SUPPORT = false;// See here https://github.com/JonnyBurger/remotion/issues/185 what// the breaking changes areexport const FEATURE_FLAG_V2_BREAKING_CHANGES = true;--// Mount extra instances of the video to allow for richer video preview-export const FEATURE_FLAG_RICH_PREVIEWS = false;diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.tsindex 17dfd54dc2..213bb7ae7d 100644--- a/packages/core/src/internals.ts+++ b/packages/core/src/internals.ts@@ -46,7 +46,6 @@ import {} from './config/webpack-caching';import {FEATURE_FLAG_FIREFOX_SUPPORT,- FEATURE_FLAG_RICH_PREVIEWS,FEATURE_FLAG_V2_BREAKING_CHANGES,} from './feature-flags';import {isAudioCodec} from './is-audio-codec';@@ -87,7 +86,6 @@ export const Internals = {FEATURE_FLAG_FIREFOX_SUPPORT,DEFAULT_WEBPACK_CACHE_ENABLED,FEATURE_FLAG_V2_BREAKING_CHANGES,- FEATURE_FLAG_RICH_PREVIEWS,getBrowser,DEFAULT_BROWSER,getDefaultCrfForCodec,