🎥 Make videos programmatically with React
add playbackRate back
Igor Samokhovets62536c03c602
diff --git a/packages/docs/docs/media/audio.mdx b/packages/docs/docs/media/audio.mdxindex 2c323b0063..3f9b8580b0 100644--- a/packages/docs/docs/media/audio.mdx+++ b/packages/docs/docs/media/audio.mdx@@ -126,7 +126,7 @@ A name and that will be shown as the label of the sequence in the timeline of th### `playbackRate?`-**Currently not supported!**+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.### `loop?`<AvailableFrom v="3.2.29" />diff --git a/packages/docs/docs/media/video.mdx b/packages/docs/docs/media/video.mdxindex e3f791302b..9ef82a105b 100644--- a/packages/docs/docs/media/video.mdx+++ b/packages/docs/docs/media/video.mdx@@ -10,7 +10,7 @@ Not to be confused with the older [`<Video>`](/docs/video) tag from `remotion`.::::::warning-**Very experimental**: This component is in a very early stage and does not support some basic features such as playback rate or CSS styling.+**Very experimental**: This component is in a very early stage and does not support some basic features such as CSS styling.The current focus is on correctness, not on performance.We recommend that you use [`<OffthreadVideo />`](/docs/offthreadvideo) for now.@@ -120,13 +120,9 @@ export const MyVideo = () => {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.-### `onError?`--**Currently not supported!**-### `playbackRate?`-**Currently not supported!**+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.### `muted?`@@ -181,10 +177,6 @@ export const MyComposition = () => {};```-### `loopVolumeCurveBehavior?`--**Currently not supported!**-### `pauseWhenBuffering?`If set to `true` and the video is loading, the Player will enter into the [native buffering state](/docs/player/buffer-state). The default is `false`, but will become `true` in Remotion 5.0.diff --git a/packages/media/src/audio/audio.tsx b/packages/media/src/audio/audio.tsxindex 274795c0cc..d6e0372b17 100644--- a/packages/media/src/audio/audio.tsx+++ b/packages/media/src/audio/audio.tsx@@ -33,6 +33,7 @@ export const Audio: React.FC<AudioProps> = (props) => {stack,showInTimeline,loop,+ playbackRate,...otherProps} = props;const environment = useRemotionEnvironment();@@ -134,6 +135,7 @@ export const Audio: React.FC<AudioProps> = (props) => {pauseWhenBuffering={pauseWhenBuffering ?? false}_remotionInternalNeedsDurationCalculation={Boolean(loop)}showInTimeline={showInTimeline ?? true}+ playbackRate={playbackRate}/>);};diff --git a/packages/media/src/audio/props.ts b/packages/media/src/audio/props.tsindex cdc0845e69..1b89624000 100644--- a/packages/media/src/audio/props.ts+++ b/packages/media/src/audio/props.ts@@ -19,4 +19,5 @@ export type AudioProps = {logLevel?: LogLevel;loop?: boolean;_remotionInternalNativeLoopPassed?: boolean;+ playbackRate?: number;};diff --git a/packages/media/src/video/props.ts b/packages/media/src/video/props.tsindex 6c6a892717..4cd3bf16a4 100644--- a/packages/media/src/video/props.ts+++ b/packages/media/src/video/props.ts@@ -20,4 +20,5 @@ export type VideoProps = {stack?: string;logLevel?: LogLevel;loop?: boolean;+ playbackRate?: number;};diff --git a/packages/media/src/video/video-for-rendering.tsx b/packages/media/src/video/video-for-rendering.tsxindex 040ee434f3..4073f26d48 100644--- a/packages/media/src/video/video-for-rendering.tsx+++ b/packages/media/src/video/video-for-rendering.tsx@@ -27,10 +27,14 @@ export const VideoForRendering: React.FC<VideoProps> = ({logLevel = window.remotion_logLevel,loop,style,+ playbackRate,className,}) => {const absoluteFrame = Internals.useTimelinePosition();const {fps} = useVideoConfig();++ const actualFps = playbackRate ? fps / playbackRate : fps;+const canvasRef = useRef<HTMLCanvasElement>(null);const {registerRenderAsset, unregisterRenderAsset} = useContext(Internals.RenderAssetManager,@@ -76,8 +80,8 @@ export const VideoForRendering: React.FC<VideoProps> = ({return;}- const timestamp = frame / fps;- const durationInSeconds = 1 / fps;+ const timestamp = frame / actualFps;+ const durationInSeconds = 1 / actualFps;const newHandle = delayRender(`Extracting frame number ${frame}`, {retries: delayRenderRetries ?? undefined,@@ -149,7 +153,7 @@ export const VideoForRendering: React.FC<VideoProps> = ({delayRenderRetries,delayRenderTimeoutInMilliseconds,environment.isClientSideRendering,- fps,+ actualFps,frame,id,logLevel,