Skip to content

Commit 7983005

Browse files
committed
Fix athletes eye default duration
1 parent a0db1e8 commit 7983005

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/template-athletes-eye/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ videoSrc: staticFile("activity.mp4"),
2727
gpxSrc: staticFile("activity.gpx"),
2828
```
2929

30+
The bundled demo video is capped to 30 seconds so the Studio timeline stays
31+
responsive. Your own video uses its full media duration by default. To cap a
32+
long activity video, add `durationInSeconds` to the default props.
33+
3034
The GPX file should contain a track with latitude, longitude, elevation and time values.
3135

3236
## Render

packages/template-athletes-eye/src/AthletesEye.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const athletesEyeSchema = z.object({
2121
videoSrc: z.string(),
2222
gpxSrc: z.string(),
2323
accentColor: z.string(),
24+
durationInSeconds: z.number().positive().optional(),
2425
});
2526

2627
export type AthletesEyeProps = z.infer<typeof athletesEyeSchema>;

packages/template-athletes-eye/src/Root.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,35 @@ import { Composition, staticFile } from "remotion";
33
import { AthletesEye, athletesEyeSchema } from "./AthletesEye";
44

55
const FPS = 30;
6+
const DEFAULT_VIDEO_SRC = "https://remotion.media/BigBuckBunny.mp4";
7+
const DEFAULT_DEMO_DURATION_IN_SECONDS = 30;
68

79
export const RemotionRoot: React.FC = () => {
810
return (
911
<Composition
1012
calculateMetadata={async ({ props }) => {
1113
const metadata = await getVideoMetadata(props.videoSrc);
14+
const durationInSeconds =
15+
props.durationInSeconds ??
16+
(props.videoSrc === DEFAULT_VIDEO_SRC
17+
? DEFAULT_DEMO_DURATION_IN_SECONDS
18+
: metadata.durationInSeconds);
1219

1320
return {
14-
durationInFrames: Math.floor(metadata.durationInSeconds * FPS),
21+
durationInFrames: Math.max(
22+
1,
23+
Math.floor(
24+
Math.min(durationInSeconds, metadata.durationInSeconds) * FPS,
25+
),
26+
),
1527
fps: FPS,
1628
};
1729
}}
1830
component={AthletesEye}
1931
defaultProps={{
2032
accentColor: "#20e3b2",
2133
gpxSrc: staticFile("sample.gpx"),
22-
videoSrc: "https://remotion.media/BigBuckBunny.mp4",
34+
videoSrc: DEFAULT_VIDEO_SRC,
2335
}}
2436
fps={FPS}
2537
height={1920}

0 commit comments

Comments
 (0)