Sizing
The following algorithm is used for calculating the size of the Player:
compositionHeight and compositionWidth props.
height and width is defined using
the style property, the player will assume the dimensions you have
passed.
height is passed using the style property,
the player will assume that height, and calculate the width based on the aspect
ratio of the video.
width is passed using the style property,
the player will assume that width and calculate the height based on the aspect
ration of the video.
Before v3.3.43, if case
aspect-ratio CSS property.Full width
By setting the following style:
tsxstyle={{ width: "100%" }}
tsxstyle={{ width: "100%" }}
The video will scale to the full width of the parent container, while the height will be calculated based on the aspect ratio of the video.
Fitting to a container
This is how you can make the Player fill out a container but keep the aspect ratio of the video:
Canvas.tsxtsximport {Player } from '@remotion/player';importReact from 'react';import {AbsoluteFill } from 'remotion';constMyComp :React .FC = () => {return <AbsoluteFill style ={{backgroundColor : 'black'}} />;};export constFullscreenPlayer = () => {constcompositionWidth = 300;constcompositionHeight = 200;return (<div style ={{width : '100vw',height : '100vh',backgroundColor : 'gray',// Any container with "position: relative" will workposition : 'relative',}}><div style ={{position : 'absolute',top : 0,left : 0,right : 0,bottom : 0,margin : 'auto',aspectRatio : `${compositionWidth } / ${compositionHeight }`,maxHeight : '100%',maxWidth : '100%',}}><Player controls component ={MyComp }compositionWidth ={compositionWidth }compositionHeight ={compositionHeight }durationInFrames ={200}fps ={30}style ={{width : '100%',}}/></div ></div >);};
Canvas.tsxtsximport {Player } from '@remotion/player';importReact from 'react';import {AbsoluteFill } from 'remotion';constMyComp :React .FC = () => {return <AbsoluteFill style ={{backgroundColor : 'black'}} />;};export constFullscreenPlayer = () => {constcompositionWidth = 300;constcompositionHeight = 200;return (<div style ={{width : '100vw',height : '100vh',backgroundColor : 'gray',// Any container with "position: relative" will workposition : 'relative',}}><div style ={{position : 'absolute',top : 0,left : 0,right : 0,bottom : 0,margin : 'auto',aspectRatio : `${compositionWidth } / ${compositionHeight }`,maxHeight : '100%',maxWidth : '100%',}}><Player controls component ={MyComp }compositionWidth ={compositionWidth }compositionHeight ={compositionHeight }durationInFrames ={200}fps ={30}style ={{width : '100%',}}/></div ></div >);};