Skip to content

🎥 Make videos programmatically with React

delete frame accuracy test from main branch

Jonny Burger1f98d28d5ea1
diff --git a/tests/frame-accuracy.test.ts b/tests/frame-accuracy.test.ts
deleted file mode 100644
index c98e5498b4..0000000000
--- a/tests/frame-accuracy.test.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import execa from "execa";
-import fs from "fs";
-import os from "os";
-import path from "path";
-import sharp from "sharp";
-
-import {selectColor} from "../packages/example/src/Framer";
-
-test('should render correct frames from embedded videos', async () => {
- const outputPath = await fs.promises.mkdtemp(
- path.join(os.tmpdir(), 'remotion-')
- );
-
- // render the VideoTesting example (which contains the Framer composition embedded with <Video>) to an image
- // sequence which can be checked for accuracy
- await execa(
- "npx",
- [
- "remotion",
- "render",
- "src/index.tsx",
- "video-testing",
- outputPath,
- "--image-format",
- "jpeg",
- "--quality",
- "100",
- "--sequence",
- ],
- {
- cwd: "packages/example",
- reject: false,
- }
- );
-
- let missedFrames = 0;
-
- for (let frame = 0; frame < 100; frame++) {
- // each frame of the embedded video contains a (deterministically) random color which should appear correctly
- // in the rendered output
- const expectedColor = {
- red: selectColor('red', frame),
- green: selectColor('green', frame),
- blue: selectColor('blue', frame),
- };
-
- // extract the actual RGB color value of the top left pixel in the frame image that was generated by remotion
- const paddedIndex = String(frame).padStart(2, '0');
- const filename = path.join(outputPath, `element-${paddedIndex}.jpeg`);
- const img = await sharp(filename).raw().toBuffer();
-
- const actualColor = {
- red: img.readUInt8(0),
- green: img.readUInt8(1),
- blue: img.readUInt8(2),
- };
-
- const colorDistance = {
- red: Math.abs(expectedColor.red - actualColor.red),
- green: Math.abs(expectedColor.green - actualColor.green),
- blue: Math.abs(expectedColor.blue - actualColor.blue),
- };
-
- // encoding sometimes shifts the color slightly - so measure the distance between the expected and actual
- // colors and consider any frame not within an acceptable range to be wrong
- if (colorDistance.red > 5 || colorDistance.green > 5 || colorDistance.blue > 5) {
- missedFrames++;
- }
- }
-
- expect(missedFrames).toBe(0);
-});
\ No newline at end of file