Skip to content

πŸŽ₯ Make videos programmatically with React

Create 2021-07-09-remotion-2-2.md

Jonny Burger0e8d8d30fa21
diff --git a/packages/docs/blog/2021-07-09-remotion-2-2.md b/packages/docs/blog/2021-07-09-remotion-2-2.md
new file mode 100644
index 0000000000..86a03d62df
--- /dev/null
+++ b/packages/docs/blog/2021-07-09-remotion-2-2.md
@@ -0,0 +1,165 @@
+---
+slug: 2-2
+title: Remotion 2.2
+author: Jonny Burger
+author_title: Remotion Creator
+author_url: https://github.com/JonnyBurger
+author_image_url: https://avatars2.githubusercontent.com/u/1629785?s=460&u=12eb94da6070d00fc924761ce06e3a428d01b7e9&v=4
+---
+
+import { ThreeDPlayer } from "../components/3DPhonePlayer.tsx";
+
+Welcome to the release notes of Remotion 2.2! It's been a while since v2.1, but in the meanwhile we had a dozen smaller releases inbetween. This post summarizes the highlights of the past 2 months πŸŽ‰.
+
+## Environment variable support
+
+Us developers use environment variables extensively to manage configuration, secrets and other stuff you don't want to commit to a Github repo. If you write videos with code, environment variables are useful too!
+
+We added support for environment variables from the CLI, using a `.env` file, and allowing you to pass variables via our Node.JS APIs too. [Click here to learn more.](/docs/env-variables)
+
+## `<Freeze />` component
+
+This new core component will freeze all of it's children and make them think that the video is paused at a certain time.
+
+Use it for example to display a still frame from a video:
+
+```tsx twoslash title="MyVideo.tsx"
+import {Freeze, Video} from 'remotion';
+import myVid from './vid.mp4';
+
+export const MyVideo = () => {
+ return (
+ <Freeze frame={30}>
+ <Video src={myVid} />
+ </Freeze>
+ )
+}
+```
+
+However, it works for any content. As you can see the API is dead simple. You can combine it with the [`<Sequence>`](/docs/sequence) API to make any content play, pause, and then continue again.
+
+[Read more about the `<Freeze />` component here.](/docs/freeze)
+
+## Video + Audio `playbackRate`
+
+This prop allows you to slow down or speed up video and audio elements! Now you can import a video in normal speed and play it in slow motion or timelapse without rerendering the video.
+
+```tsx twoslash title="LightningSpeed.tsx"
+import {Video} from 'remotion';
+import myVid from './vid.mp4';
+
+export const MyVideo = () => {
+ return (
+ <Video src={myVid} playbackRate={4}/>
+ )
+}
+```
+
+While previewing, we are using the HTML5 `playbackRate` API, and when rendering, we will calculate the correct FFMPEG command for any tempo.
+
+Learn more about the `playbackRate` props for [`<Audio />`](/docs/audio/#controlling-playback-speed) and [`<Video />`](/docs/video/#controlling-playback-speed).
+
+## `@remotion/three` package
+
+In case you missed it, we released a new helper package for [React Three Fiber](https://github.com/pmndrs/react-three-fiber)!
+
+<ThreeDPlayer />
+<br/>
+
+Three.JS is admittedly not easy, but with the work that [Poimandres](https://github.com/pmndrs) is doing in making it more approachable and more integrated with React, this is changing rapidly. Creating 3D videos in React and rendering them to real MP4 videos, we are making it possible!
+
+Learn more about [`@remotion/three`](/docs/three) and get started using our [template](https://github.com/remotion-dev/template-three).
+
+## ProRes support and MKV support
+
+Creating MP4 videos with React, that's just our marketing tagline. We support a lot of other codecs too, [like H265, WebM even transparent ones!](/docs/encoding)
+
+We have now added two more:
+
+- ProRes is a codec suitable for video editors using Final Cut Pro, Adobe Premiere or Davinci Resolve. Say you want to create an overlay animation using Remotion and use it in a traditional video cutting program, you can now use ProRes to export the video with an alpha channel and import it many other programs losslessly.
+
+- The Matroska container format (which can be recognized using the `.mkv` extension) is a format that commonly also just contains the H.264 videos, the same codec used for MP4s. However it has more flexibility for audio and allows lossless audio streams to be contained by the format. MKV support will come in handy for an upcoming Remotion feature, and is the first step in allowing us to go to the moon.
+
+Read the [Encoding guide](/docs/encoding) to see an overview of all options.
+
+## `<Player />` updates
+
+The [`@remotion/player`](/docs/player), currently still experimental, allows Remotion videos to be played on the web without having to encode them. We've made the following progress towards getting it stable:
+
+### Audio controls
+
+A player now has a volume slider, and a mute button to allow the user to control the video. You can decide whether you want to display these controls using the `showVolumeControls` prop.
+
+Audio can also be controlled programmatically. We added the methods `getVolume()`, `setVolume()`, `mute()`, `unmute()` and `isMuted()` to allow you to implement your own solutions.
+
+### `timeupdate` event
+
+Inspired by the HTML5 event with the same name, we added a `timeupdate` event to the Player. Unlike the `seeked` event, it does not fire on every frame, so if you want only periodic updates about the time being updated, you can use this event without having to throttle it.
+
+### `clickToPlay` prop
+
+This prop allows you to control whether the user is allowed to click on the video to make it pause or play. It is true by default if the controls of the player are enabled.
+
+### `doubleClickToFullscreen` prop
+
+This prop allows you to control whether the user is allowed to double click on the video to make it go fullscreen. If enabled, single-clicking to pause the video will have a short delay in order to wait for a potential second click.
+
+## Timeline scroll position gets persisted
+
+When coding a video, and refreshing the preview, the video would jump back to the first frame which was annoying. Not anymore - if you refresh you are back where you left off!
+
+## Specify a custom `--port`
+
+By default the Remotion preview starts a server on port 3000. Should you want to have it start on a different port for any reason, you can now pass a CLI flag.
+
+## More helpful error handling
+
+We want to help you out whenever you are facing a tricky issue. Here are some examples of scenarios where we now give you a helpful warning and linking to the documentation:
+
+- Multiple versions of Remotion are imported on a page (for example when using the `<Player />` in your app)
+- A video is loaded that does not support seeking (for example when serving from Google Cloud Storage)
+- A video with an unsupported codec is loaded (for example an MP4 in the Chromium browser)
+- A `delayRender()` handle has been created but never cleared
+
+## Documentation upgrades
+
+### Search
+
+We now have a search at the top right of the docs! Thanks to Algolia for hosting the widget and indexing the documentation.
+
+### Type hints
+
+Did you notice it in the snippets above? You can now hover over any symbol and see it's type. It's powered by Typescript + Twoslash. A really nice side effect is that it's now impossible for us to make typos in the documentation since all snippets are type checked.
+
+### Troubleshooting guides
+
+We now have [help articles on various issues](/docs/timeout) that you may face. Currently we have written about 6 common problems, and put them in a new section of the docs called Troubleshooting.
+
+### Page about third party integrations
+
+[A new page](/docs/third-party) has been created listing some popular libraries and describing how well they work together with Remotion - or don't.
+
+### New landing page
+
+Finally, the [homepage of Remotion](https://remotion.dev) got a makeover! We hope to better communicate what Remotion is and why it's awesome.
+
+## Various Bugfixes
+
+- Fixed a memory leak while calling getCompositions(). (28f86f24)
+- Add emoji support to Dockerfile (#476)
+- The preview now shows the current time within a sequence in a timeline (d925768f)
+- TTF fonts can now be loaded locally
+- Fix Remotion Player assuming it's in a rendering environment
+- Fix getAudioMetadata() and getAudioDuration() not returning an error in the `onError` event (1ea7b151)
+- Added documentation on how to use TailwindCSS
+- Fixed documentation about how to use SASS/SCSS
+- If you are using a plain JS entry file, you can also use a remotion.config.js config file.
+- You can customize how many timeline tracks should be shown at most using `Config.Preview.setMaxTimelineTracks()`
+- Fixed a bug where environment variables would not be immediately accessible
+- Input props flag can now also be passed for preview
+- Better input validation of the most common functions
+- Improve rendering of very long videos, using less memory and avoiding a Maximum callstack exceeded error message.
+- Setting `crf` to 0 is not allowed anymore for H264 videos as it will lead to a video that does not play on all platforms.
+- The docs for `<Sequence />` now have interactive examples.
+- A lot of tests have been added to the core functions.
+- The Typescript types have been improved to allow for more types of components to be passed to `component`.