Skip to content

🎥 Make videos programmatically with React

`@remotion/media`: Allow frames to be off by 1ms

JonnyBurgera28f0b221e05
diff --git a/packages/media/src/video-extraction/keyframe-bank.ts b/packages/media/src/video-extraction/keyframe-bank.ts
index ba1597ed66..cbb7fc4e58 100644
--- a/packages/media/src/video-extraction/keyframe-bank.ts
+++ b/packages/media/src/video-extraction/keyframe-bank.ts
@@ -59,7 +59,7 @@ export const makeKeyframeBank = ({
return (
roundTo4Digits(lastFrame.timestamp + lastFrame.duration) >
- roundTo4Digits(timestamp)
+ roundTo4Digits(timestamp) + 0.001
);
};
@@ -117,7 +117,11 @@ export const makeKeyframeBank = ({
}
if (
- roundTo4Digits(sample.timestamp) <= roundTo4Digits(timestampInSeconds)
+ roundTo4Digits(sample.timestamp) <=
+ roundTo4Digits(timestampInSeconds) ||
+ // Match 0.3333333333 to 0.33355555
+ // this does not satisfy the previous condition, since one rounds up and one rounds down
+ Math.abs(sample.timestamp - timestampInSeconds) < 0.001
) {
return sample;
}