Skip to content

Instantly share code, notes, and snippets.

@jryebread
Created August 18, 2024 01:29
Show Gist options
  • Save jryebread/0ed730ca3b8914c0c02af0ffc0ca2301 to your computer and use it in GitHub Desktop.
Save jryebread/0ed730ca3b8914c0c02af0ffc0ca2301 to your computer and use it in GitHub Desktop.
``` return (
<AbsoluteFill>
<AbsoluteFill>
<OffthreadVideo pauseWhenBuffering={true} src={src} />
</AbsoluteFill>
{/* Render Broll Videos */}
{groupedBroll.map((brollGroup: any, index: number) => {
if (!brollGroup.broll) return null;
const startFrame = Math.round(brollGroup.start * fps);
const endFrame = Math.round(brollGroup.end * fps);
const durationInFrames = endFrame - startFrame;
return (
<Sequence key={`broll-${index}`} from={startFrame} premountFor={100}>
<OffthreadVideo pauseWhenBuffering={true}
src={brollGroup.broll.url}
startFrom={Math.max(0, startFrame)}
endAt={Math.max(0, endFrame)}
style={{
position: 'absolute',
top: 0,
left: 0,
width: '200%',
height: '100%',
transform: 'scale(1.2)',
}}
/>
</Sequence>
);
})}
{subtitleGroups.map((group, index) => {
const startFrame = Math.round(group.start * fps);
const endFrame = Math.round(group.end * fps);
const durationInFrames = endFrame - startFrame;
if (durationInFrames <= 0) {
return null;
}
return (<>
<Sequence
key={index}
from={startFrame}
durationInFrames={durationInFrames}
>
<Subtitle
font_size={(group.font_size != 0) ? group.font_size : style.fontSize}
position_y={(group.position_y != 0) ? group.position_y : style.positionY}
frame={frame}
group={group}
words={group.words}
maxWordsPerLine={group.words.length}
style={style}
/>
</Sequence></>
);
})}
{!loading && subtitleGroups.length === 0 && <NoCaptionFile />}
</AbsoluteFill>
);
};```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment