Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply best practices for creating programmatic videos with Remotion and React.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/videos.md
1---2name: videos3description: Embedding videos in Remotion - trimming, volume, speed, looping, pitch4metadata:5tags: video, media, trim, volume, speed, loop, pitch6---78# Using videos in Remotion910## Prerequisites1112First, the @remotion/media package needs to be installed.13If it is not, use the following command:1415```bash16npx remotion add @remotion/media # If project uses npm17bunx remotion add @remotion/media # If project uses bun18yarn remotion add @remotion/media # If project uses yarn19pnpm exec remotion add @remotion/media # If project uses pnpm20```2122Use `<Video>` from `@remotion/media` to embed videos into your composition.2324```tsx25import { Video } from "@remotion/media";26import { staticFile } from "remotion";2728export const MyComposition = () => {29return <Video src={staticFile("video.mp4")} />;30};31```3233Remote URLs are also supported:3435```tsx36<Video src="https://remotion.media/video.mp4" />37```3839## Trimming4041Use `trimBefore` and `trimAfter` to remove portions of the video. Values are in seconds.4243```tsx44const { fps } = useVideoConfig();4546return (47<Video48src={staticFile("video.mp4")}49trimBefore={2 * fps} // Skip the first 2 seconds50trimAfter={10 * fps} // End at the 10 second mark51/>52);53```5455## Delaying5657Wrap the video in a `<Sequence>` to delay when it appears:5859```tsx60import { Sequence, staticFile } from "remotion";61import { Video } from "@remotion/media";6263const { fps } = useVideoConfig();6465return (66<Sequence from={1 * fps}>67<Video src={staticFile("video.mp4")} />68</Sequence>69);70```7172The video will appear after 1 second.7374## Sizing and Position7576Use the `style` prop to control size and position:7778```tsx79<Video80src={staticFile("video.mp4")}81style={{82width: 500,83height: 300,84position: "absolute",85top: 100,86left: 50,87objectFit: "cover",88}}89/>90```9192## Volume9394Set a static volume (0 to 1):9596```tsx97<Video src={staticFile("video.mp4")} volume={0.5} />98```99100Or use a callback for dynamic volume based on the current frame:101102```tsx103import { interpolate } from "remotion";104105const { fps } = useVideoConfig();106107return (108<Video109src={staticFile("video.mp4")}110volume={(f) =>111interpolate(f, [0, 1 * fps], [0, 1], { extrapolateRight: "clamp" })112}113/>114);115```116117Use `muted` to silence the video entirely:118119```tsx120<Video src={staticFile("video.mp4")} muted />121```122123## Speed124125Use `playbackRate` to change the playback speed:126127```tsx128<Video src={staticFile("video.mp4")} playbackRate={2} /> {/* 2x speed */}129<Video src={staticFile("video.mp4")} playbackRate={0.5} /> {/* Half speed */}130```131132Reverse playback is not supported.133134## Looping135136Use `loop` to loop the video indefinitely:137138```tsx139<Video src={staticFile("video.mp4")} loop />140```141142Use `loopVolumeCurveBehavior` to control how the frame count behaves when looping:143144- `"repeat"`: Frame count resets to 0 each loop (for `volume` callback)145- `"extend"`: Frame count continues incrementing146147```tsx148<Video149src={staticFile("video.mp4")}150loop151loopVolumeCurveBehavior="extend"152volume={(f) => interpolate(f, [0, 300], [1, 0])} // Fade out over multiple loops153/>154```155156## Pitch157158Use `toneFrequency` to adjust the pitch without affecting speed. Values range from 0.01 to 2:159160```tsx161<Video162src={staticFile("video.mp4")}163toneFrequency={1.5} // Higher pitch164/>165<Video166src={staticFile("video.mp4")}167toneFrequency={0.8} // Lower pitch168/>169```170171Pitch shifting only works during server-side rendering, not in the Remotion Studio preview or in the `<Player />`.172