Back to Remotion

Trimming Audio

packages/docs/docs/audio/trimming.mdx

4.0.501969 B
Original Source

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

The <Audio /> and <Video /> tags support the trimBefore and trimAfter props.
<Html5Audio /> also supports these props.

tsx
import {AbsoluteFill, staticFile, useVideoConfig} from 'remotion';
import {Video} from '@remotion/media';

export const MyComposition = () => {
  const {fps} = useVideoConfig();

  return (
    <AbsoluteFill>
      <Video src={staticFile('video.mp4')} trimBefore={2 * fps} trimAfter={4 * fps} />
    </AbsoluteFill>
  );
};

This makes the media play the range from 00:02:00 to 00:04:00, meaning it will play for 2 seconds.

The audio will still play immediately at the beginning - to see how to shift the audio to appear later in the composition, see the next article.