import {createTikTokStyleCaptions, type Caption} from '@remotion/captions'; import React, {useMemo} from 'react'; import { AbsoluteFill, Interactive, Series, useCurrentFrame, useVideoConfig, type InteractiveTransformProps, } from 'remotion'; const CaptionsContent: React.FC< InteractiveTransformProps & {readonly captions: Caption[]} > = ({captions, style}) => { const frame = useCurrentFrame(); const {fps} = useVideoConfig(); const {pages} = useMemo( () => createTikTokStyleCaptions({ captions, combineTokensWithinMilliseconds: 3000, }), [captions], ); const currentTimeMs = (frame / fps) * 1000; const page = pages.find( (candidate) => currentTimeMs >= candidate.startMs && currentTimeMs < candidate.startMs + candidate.durationMs, ); return
{page?.text.trim()}
; }; const BasicCaptions = Interactive.withSchema({ Component: CaptionsContent, componentName: '', schema: Interactive.captionsSchema, wrapInSequence: true, }); // https://github.com/remotion-dev/remotion/issues/11891 // In Visual Mode, expand "Presenter introduction (2)" and drag the left edge // of its captions to the right. The captions' visible start should move. // The captions' timing and right edge should stay unchanged. export const CaptionLeftEdgeTrimRepro: React.FC = () => { return ( Caption left edge trim reproduction ); };