<NewVideo>
Very experimental: This component is in a very early stage and slower than OffthreadVideo.
The current focus is on correctness, not on performance.
We recommend that you use <OffthreadVideo/>
for now.
This component imports and displays a video, similar to <OffthreadVideo/>
but during rendering, extracts the exact frame from the video using WebCodecs and displays it in a <canvas>
tag.
Example
tsx
import {AbsoluteFill ,staticFile } from 'remotion';import {experimental_NewVideo asNewVideo } from '@remotion/video';export constMyVideo = () => {return (<AbsoluteFill ><NewVideo src ={staticFile ('video.webm')} /></AbsoluteFill >);};
You can load a video from an URL as well:
tsx
export constMyComposition = () => {return (<AbsoluteFill ><NewVideo src ="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" /></AbsoluteFill >);};
Props
src
The URL of the video to be rendered. Can be a remote URL or a local file referenced with staticFile()
.
trimBefore?
v4.0.319
Will remove a portion of the video at the beginning (left side).
In the following example, we assume that the fps
of the composition is 30
.
By passing trimBefore={60}
, the playback starts immediately, but with the first 2 seconds of the video trimmed away.
By passing trimAfter={120}
, any video after the 4 second mark in the file will be trimmed away.
The video will play the range from 00:02:00
to 00:04:00
, meaning the video will play for 2 seconds.
For exact behavior, see: Order of operations.
tsx
export constMyComposition = () => {return (<AbsoluteFill ><NewVideo src ={staticFile ('video.webm')}trimBefore ={60}trimAfter ={120} /></AbsoluteFill >);};
trimAfter?
v4.0.319
Removes a portion of the video at the end (right side). See trimBefore
for an explanation.
volume?
Allows you to control the volume for the whole track or change it on a per-frame basis. Refer to the using audio guide to learn how to use it.
Example using static volumetsx
export constMyComposition = () => {return (<AbsoluteFill ><NewVideo volume ={0.5}src ={staticFile ('video.webm')} /></AbsoluteFill >);};
Example of a ramp up over 100 framestsx
export constMyComposition = () => {return (<AbsoluteFill ><NewVideo volume ={(f ) =>interpolate (f , [0, 100], [0, 1], {extrapolateLeft : 'clamp'})}src ={staticFile ('video.webm')} /></AbsoluteFill >);};
By default, volumes between 0 and 1 are supported, where in iOS Safari, the volume is always 1.
See Volume Limitations for more information.
loopVolumeCurveBehavior?
v4.0.142
Controls the frame
which is returned when using the volume
callback function and wrapping OffthreadVideo
in a <Loop>
.
Can be either "repeat"
(default, start from 0 on each iteration) or "extend"
(keep increasing frames).
style?
You can pass any style you can pass to a native HTML element. Keep in mind that during rendering, <NewVideo>
renders a canvas
tag, but a <video>
tag is used during preview.
tsx
export constMyComposition = () => {return (<AbsoluteFill ><Img src ={staticFile ('video.webm')}style ={{height : 720,width : 1280}} /></AbsoluteFill >);};
name?
v4.0.71
A name and that will be shown as the label of the sequence in the timeline of the Remotion Studio. This property is purely for helping you keep track of items in the timeline.
toneFrequency?
v4.0.47
Adjust the pitch of the audio - will only be applied during rendering.
Accepts a number between 0.01
and 2
, where 1
represents the original pitch. Values less than 1
will decrease the pitch, while values greater than 1
will increase it.
A toneFrequency
of 0.5 would lower the pitch by half, and a toneFrequency
of 1.5
would increase the pitch by 50%.
onError?
Handle an error playing the video. From v3.3.89, if you pass an onError
callback, then no exception will be thrown. Previously, the error could not be caught.
playbackRate?
v2.2.0
Controls the speed of the video. 1
is the default and means regular speed, 0.5
slows down the video so it's twice as long and 2
speeds up the video so it's twice as fast.
While Remotion doesn't limit the range of possible playback speeds, in development mode the HTMLMediaElement.playbackRate
API is used which throws errors on extreme values. At the time of writing, Google Chrome throws an exception if the playback rate is below 0.0625
or above 16
.
Example of a video playing twice as fasttsx
export constMyComposition = () => {return (<AbsoluteFill ><NewVideo playbackRate ={2}src ={staticFile ('video.webm')} /></AbsoluteFill >);};
muted?
You can drop the audio of the video by adding a muted
prop:
Example of a muted videotsx
export constMyComposition = () => {return (<AbsoluteFill ><NewVideo muted src ="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" /></AbsoluteFill >);};
acceptableTimeShiftInSeconds?
v3.2.42
In the Studio or in the Remotion Player, Remotion will seek the video if it gets too much out of sync with Remotion's internal time - be it due to the video loading or the page being too slow to keep up in real-time. By default, a seek is triggered if 0.45
seconds of time shift is encountered. Using this prop, you can customize the threshold.
toneFrequency?
v4.0.47
Adjust the pitch of the audio - will only be applied during rendering.
Accepts a number between 0.01
and 2
, where 1
represents the original pitch. Values less than 1
will decrease the pitch, while values greater than 1
will increase it.
A toneFrequency
of 0.5 would lower the pitch by half, and a toneFrequency
of 1.5
would increase the pitch by 50%.
pauseWhenBuffering?
v4.0.111
If set to true
and the video is loading, the Player will enter into the native buffering state. The default is false
, but will become true
in Remotion 5.0.
showInTimeline?
v4.0.122
If set to false
, no layer will be shown in the timeline of the Remotion Studio. The default is true
.
delayRenderTimeoutInMilliseconds?
v4.0.150
Customize the timeout of the delayRender()
call that this component makes.
delayRenderRetries?
v4.0.178
Customize the number of retries of the delayRender()
call that this component makes.
onAutoPlayError?
v4.0.187
A callback function that gets called when the video fails to play due to autoplay restrictions.
If you don't pass a callback, the video will be muted and be retried once.
This prop is useful if you want to handle the error yourself, e.g. for pausing the Player.
Read more here about autoplay restrictions.
onVideoFrame?
v4.0.190
A callback function that gets called when a frame is extracted from the video.
Useful for video manipulation.
The callback is called with a CanvasImageSource
object.
During preview, this is a HTMLVideoElement
object, during rendering, it is an HTMLImageElement
.
crossOrigin?
v4.0.190
Corresponds to the crossOrigin
attribute of the <video>
element.
One of "anonymous"
, "use-credentials"
or undefined
.
Default: "anonymous"
if onVideoFrame
is specified, undefined
, otherwise.
useWebAudioApi?
v4.0.306
Enable the Web Audio API for the video tag.