Skip to content

Instantly share code, notes, and snippets.

@kernalphage
Created December 4, 2022 17:49
Show Gist options
  • Save kernalphage/14c7ebe1c1cc697af1f9999d6b5c6014 to your computer and use it in GitHub Desktop.
Save kernalphage/14c7ebe1c1cc697af1f9999d6b5c6014 to your computer and use it in GitHub Desktop.
An example of how to stitch together Series.Sequences in Remotion
export const TimedSequence: React.FC<{ urls: string[]}> = ({ urls }) => {
const [allCues, setAllCues] = useState<>(undefined);
const [handle] = useState(() => delayRender());
const {fps} = useVideoConfig();
const fetchData = useCallback(async () => {
const all = await Promise.all(urls.map(async (url) =>
({url, durationInSeconds: await getAudioDurationInSeconds(url)})
));
setAllCues(all);
continueRender(handle);
}, [handle]);
useEffect(() => {
fetchData();
}, [fetchData]);
if (allCues) {
return (
<Series>
{allCues.map((cue, i) => (
<Series.Sequence
key={cue.url+i}
durationInFrames={Math.floor(cue.durationInSeconds * fps)}
>
<Audio src={cue.url} />
</Series.Sequence>
))}
</Series>
)
}
return (
<div style={{ fontSize: "2em" }}>
fetching {urls.join("")}
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment