Skip to content

🎥 Make videos programmatically with React

`@remotion/renderer`: Fix rounding floating point errors

Jonny Burger82190efdeb19
diff --git a/packages/renderer/src/stringify-ffmpeg-filter.ts b/packages/renderer/src/stringify-ffmpeg-filter.ts
index 638fc6bffa..61d552993d 100644
--- a/packages/renderer/src/stringify-ffmpeg-filter.ts
+++ b/packages/renderer/src/stringify-ffmpeg-filter.ts
@@ -16,6 +16,18 @@ export type ProcessedTrack = {
pad_end: string | null;
};
+const cleanUpFloatingPointError = (value: number) => {
+ if (value % 1 < 0.0000001) {
+ return Math.floor(value);
+ }
+
+ if (value % 1 > 0.9999999) {
+ return Math.ceil(value);
+ }
+
+ return value;
+};
+
const stringifyTrim = (trim: number) => {
const value = trim * 1_000_000;
const asString = `${value}us`;