Jump Cutting
You might wanna use a "jump cut" to skip parts of a video.
Use the following snippet to skip certain sections of a video, without re-mounting it.
tsx
importReact , {useMemo } from 'react';import {CalculateMetadataFunction ,OffthreadVideo ,staticFile ,useCurrentFrame } from 'remotion';constfps = 30;typeSection = {trimBefore : number;trimAfter : number;};export constSAMPLE_SECTIONS :Section [] = [{trimBefore : 0,trimAfter : 5 *fps },{trimBefore : 7 *fps ,trimAfter : 10 *fps ,},{trimBefore : 13 *fps ,trimAfter : 18 *fps ,},];typeProps = {sections :Section [];};export constcalculateMetadata :CalculateMetadataFunction <Props > = ({props }) => {constdurationInFrames =props .sections .reduce ((acc ,section ) => {returnacc +section .trimAfter -section .trimBefore ;}, 0);return {fps ,durationInFrames ,};};export constJumpCuts :React .FC <Props > = ({sections }) => {constframe =useCurrentFrame ();consttrimBefore =useMemo (() => {letsummedUpDurations = 0;for (constsection ofsections ) {summedUpDurations +=section .trimAfter -section .trimBefore ;if (summedUpDurations >frame ) {returnsection .trimAfter -summedUpDurations ;}}return null;}, [frame ,sections ]);if (trimBefore === null) {return null;}return (<OffthreadVideo pauseWhenBuffering trimBefore ={trimBefore }// Remotion will automatically add a time fragment to the end of the video URL// based on `trimBefore` and `trimAfter`. Opt out of this by adding one yourself.// https://www.remotion.dev/docs/media-fragmentssrc ={`${staticFile ('time.mp4')}#t=0,`}/>);};