Skip to content

🎥 Make videos programmatically with React

`@remotion/media`: Fix extracting a frame from after end of video

Jonny Burgercbb43556179d
diff --git a/packages/media/src/video-extraction/keyframe-bank.ts b/packages/media/src/video-extraction/keyframe-bank.ts
index 8db61d23c7..1cfc80dd66 100644
--- a/packages/media/src/video-extraction/keyframe-bank.ts
+++ b/packages/media/src/video-extraction/keyframe-bank.ts
@@ -154,14 +154,12 @@ export const makeKeyframeBank = ({
adjustedTimestamp = startTimestampInSeconds;
}
+ // If we request a timestamp after the end of the video, return the last frame
+ // same behavior as <video>
if (
roundTo4Digits(adjustedTimestamp) > roundTo4Digits(endTimestampInSeconds)
) {
- return Promise.reject(
- new Error(
- `Timestamp is after end timestamp (requested: ${timestampInSeconds}sec, end: ${endTimestampInSeconds}sec)`,
- ),
- );
+ adjustedTimestamp = endTimestampInSeconds;
}
await ensureEnoughFramesForTimestamp(adjustedTimestamp);