Skip to content

🎥 Make videos programmatically with React

render scale

Jonny Burger1a3852745bbb
diff --git a/tests/render-scale.test.ts b/tests/render-scale.test.ts
new file mode 100644
index 0000000000..bd9f70a6ce
--- /dev/null
+++ b/tests/render-scale.test.ts
@@ -0,0 +1,77 @@
+import fs from "fs";
+import execa from "execa";
+import path from "path";
+
+const outputPath = path.join(process.cwd(), "packages/example/out.mp4");
+
+beforeEach(() => {
+ if (fs.existsSync(outputPath)) {
+ fs.unlinkSync(outputPath);
+ }
+});
+
+test("Should be able to render video with scale 2", async () => {
+ const task = execa(
+ "npx",
+ [
+ "remotion",
+ "render",
+ "src/index.tsx",
+ "ten-frame-tester",
+ "--frames",
+ "0-1",
+ "--codec",
+ "h264",
+ "--scale",
+ "2",
+ outputPath,
+ ],
+ {
+ cwd: "packages/example",
+ }
+ );
+ task.stderr?.pipe(process.stderr);
+ await task;
+ const exists = fs.existsSync(outputPath);
+ expect(exists).toBe(true);
+
+ const info = await execa("ffprobe", [outputPath]);
+ const data = info.stderr;
+ expect(data).toContain("Video: h264");
+ expect(data).toContain("yuv420p");
+ expect(data).toContain("2160x2160");
+ expect(data).toContain("30 fps");
+});
+
+test("Should be able to render video with scale 0.1", async () => {
+ const task = execa(
+ "npx",
+ [
+ "remotion",
+ "render",
+ "src/index.tsx",
+ "ten-frame-tester",
+ "--frames",
+ "0-1",
+ "--codec",
+ "h264",
+ "--scale",
+ "0.1",
+ outputPath,
+ ],
+ {
+ cwd: "packages/example",
+ }
+ );
+ task.stderr?.pipe(process.stderr);
+ await task;
+ const exists = fs.existsSync(outputPath);
+ expect(exists).toBe(true);
+
+ const info = await execa("ffprobe", [outputPath]);
+ const data = info.stderr;
+ expect(data).toContain("Video: h264");
+ expect(data).toContain("yuv420p");
+ expect(data).toContain("108x108");
+ expect(data).toContain("30 fps");
+});