Skip to content

🎥 Make videos programmatically with React

remotion 1.4 blog post

Jonny Burger86a911ba45d7
diff --git a/packages/core/src/test/random.test.ts b/packages/core/src/test/random.test.ts
index 059b2eb2d9..cbce2d0116 100644
--- a/packages/core/src/test/random.test.ts
+++ b/packages/core/src/test/random.test.ts
@@ -1,5 +1,11 @@
import {random} from '../random';
+test('Should support negative random numbers', () => {
+ expect(random(-1)).toBe(random(-1));
+ expect(random(-2)).toBe(random(-2));
+ expect(random(-2)).not.toBe(random(-1));
+});
+
test('Random should be deterministic', () => {
expect(random(1)).toBe(random(1));
expect(random(2)).toBe(random(2));
diff --git a/packages/docs/blog/2021-02-25-remotion-1-4.mdx b/packages/docs/blog/2021-02-25-remotion-1-4.mdx
new file mode 100644
index 0000000000..3c8e684135
--- /dev/null
+++ b/packages/docs/blog/2021-02-25-remotion-1-4.mdx
@@ -0,0 +1,111 @@
+---
+slug: 1-4
+title: Remotion 1.4
+author: Jonny Burger
+author_title: Indie Hacker
+author_url: https://github.com/JonnyBurger
+author_image_url: https://avatars2.githubusercontent.com/u/1629785?s=460&u=12eb94da6070d00fc924761ce06e3a428d01b7e9&v=4
+---
+
+import { TransparentVideoDemo } from "../components/TransparentVideoDemo";
+
+Welcome to the release notes of Remotion 1.4! This is a big release adding support for more use cases and makes Remotion more stable, intuitive and robust.
+
+## Support for HEVC and WebM codecs
+
+Instead of just supporting H.264, you can now also encode a video in H.265 (HEVC), or as a WebM (in either VP8 or VP9 codec). These codecs will result in smaller file sizes, but have some trade-offs. To help you decide which codec to use, there is now an [encoding guide](/docs/encoding) in the docs. See also the
+documentation for changing the codec in [the config file](/docs/config#setcodec)
+as well as [in the CLI](/docs/cli#flags).
+
+## Transparent videos
+
+Did you know that Chrome and Firefox support video with alpha channels? Play the video and click the button below to dynamically change the background.
+
+<TransparentVideoDemo />
+
+Remotion now has enough configurability to enable you to render transparent videos. There is [a new documentation page](/docs/transparent-videos) for it, which also gives you guidance on how to render a fallback video for unsupported browsers.
+
+## New `random()` API
+
+Let's say you want to render 100 random particles in a video. A common mistake is to generate random values and store them in a state. The following is an anti-pattern in Remotion:
+
+```tsx {5-6}
+export const MyComp = () => {
+ // ⚠️ Bug! Random values will change during render
+ const [particles] = useState(() => {
+ return new Array(100).fill(true).map(() => ({
+ x: Math.random(),
+ y: Math.random()
+ }));
+ })
+}
+```
+
+While this will work while previewing the video, during rendering, the random numbers will change during frames. This is because Remotion spins up multiple instances of Chrome and the random numbers will be different in each instance.
+
+To help you avoid this mistake, there is now a new ESLint rule that will warn when you use `Math.random()`. Instead using it, you can use the new [`random()`](/docs/random) API. It will take a `seed` parameter and output a number between 0 and 1. The point of it is: As long as you pass the same seed, you get the same output! That way you don't get unintended effects while multithreaded rendering is performed.
+
+```tsx {7-8}
+import {random} from 'remotion';
+
+export const MyComp = () => {
+ // ✅ Pseudo-random values that will be same across threads
+ const [particles] = useState(() => {
+ return new Array(100).fill(true).map((_, idx) => ({
+ x: random(`x-${idx}`),
+ y: random(`y-${idx}`),
+ }));
+ })
+}
+```
+
+Want to learn more? Read the new documentation page about [using randomness](/docs/using-randomness).
+
+## More configuration options
+
+Several new configuration options have been added as CLI flags, config file entries and the SSR API:
+
+- [setCrf()](/docs/encoding#controlling-quality-using-the-crf-setting) controls the tradeoff between quality and file size of the output file.
+- [setQuality()](/docs/encoding#controlling-quality-using-the-crf-setting) allows you to control the JPEG quality of the frames rendered.
+- [setCodec()](/docs/config#setcodec) allows you to select between 4 different codecs (as mentioned above).
+- [setImageSequence()](/docs/config#setimagesequence) allows you to skip the stitching process and output only an image sequence
+- [setImageFormat()](/docs/config#setimageformat) allows you to explicitly select either PNG or JPEG as the format for the rendered frames.
+- [setPixelFormat()](/docs/config#setpixelformat) has a new accepted value, `yuva420p`, which is necessary for transparent videos.
+
+The addition of `setImageSequence()` and `setImageFormat()` as well as `setCodec()` makes the previous configuration options `setOutputFormat()` and `--png` obsolete. and they are therefore now deprecated. While they still work, we encourage you to use the new configuration options which are much more granular - for example now you can render a JPEG sequence if you wish to.
+
+## Keyboard controls in the editor
+
+Thanks to an [awesome pull request by Arthur Denner](https://github.com/arthurdenner), keyboard navigation in the editor is much improved! [Reading the PR](https://github.com/JonnyBurger/remotion/pull/125) is highly recommended because it's insightful to see that it's not hard to make a website keyboard-navigateable.
+
+![keyboard-support.gif](/img/keyboard-support.gif)
+
+## Progress bar for stitching frames together
+
+Don't be surprised if the new codecs which have been added are much slower than the default H.264. It's normal. But at least now you always check the progress of the rendering!
+
+![stitching-progress.png](/img/stitching-progress.png)
+
+## End to End tests for Windows, macOS and Ubuntu
+
+While Remotion is primarily developed on macOS, other operating systems shouldn't have a sub-par experience or get bugs. While it does not replace manual testing, it helps that [there are now some end-to-end tests for rendering videos](https://github.com/JonnyBurger/remotion/blob/main/tests/rendering.test.ts) and the test suite now runs on all 3 operating systems. Going forward, I will add more tests and contributors are also encouraged to do so.
+
+## Paying top contributors
+
+Since Remotion [will make money by selling licenses to bigger companies](https://github.com/JonnyBurger/remotion/blob/main/LICENSE.md), it's only fair to give contributors their share as well! I have made offers to two top contributors so far to compensate them for their time spent so far and for potential future work. Gladly, they both accepted!
+
+## Various improvements
+
+- [Fixed showing floats when fps is not a Integer (e.g 59.97fps)](https://github.com/JonnyBurger/remotion/pull/122)
+
+- [Ensure minimum node version](https://github.com/JonnyBurger/remotion/pull/117)
+
+- [Fix flickering `<Video>`](https://github.com/JonnyBurger/remotion/pull/118)
+
+- [Clean up frames after rendering](https://github.com/JonnyBurger/remotion/pull/127)
+
+- [Throw error if useVideoConfig is not used in Composition](https://github.com/JonnyBurger/remotion/pull/130)
+
+## Up next...
+
+Some awesome pull requests came in, [the most notable one adds audio support!](https://github.com/JonnyBurger/remotion/pull/128) We are also working on allowing you to customize Puppeteer parameters and making the installation process much faster by not downloading a copy of Chromium. Keep your eyes open for more major improvements coming soon.
diff --git a/packages/docs/static/img/keyboard-support.gif b/packages/docs/static/img/keyboard-support.gif
new file mode 100644
index 0000000000..af1594f6de
Binary files /dev/null and b/packages/docs/static/img/keyboard-support.gif differ
diff --git a/packages/docs/static/img/stitching-progress.png b/packages/docs/static/img/stitching-progress.png
new file mode 100644
index 0000000000..c8aea09c1c
Binary files /dev/null and b/packages/docs/static/img/stitching-progress.png differ