@revideo/renderer
Last updated
Last updated
The renderVideo
function lets you render (parameterized) videos in a nodejs process. It uses a headless browser to achieve this.
The input arguments are a RenderVideoProps
object, which has the following properties:
string
Points towards your project file. This will probably be ./src/project.ts
.
Record<string, any>
A RenderSettings
object with the following properties:
string, has to end with '.mp4'
The file name of the video output
string
The output directory of the rendered video. default="./output"
[number, number]
The start and end second of the video. Can be used to only render a part of the video.
number
The number of processes you want to use to parallelize rendering, default is 1. Rendering a 100s long video with 10 workers means that 10 processes handle 10s of video each. Your laptop will probably render fastest with one worker, but VMs with a lot of computing power can benefit from using more than one
[number, number]
Dimensions of the video to render as [x,y]. Uses the value specified in project.meta
by default.
boolean
Logs render progress to the console if set to true
.
FFmpeg options - is an instance of FfmpegSettings
. These overwrite the following settings set through environment variables:
error
| warning
| info
| verbose
, debug
| trace
The log level of FFmpeg. Can be one of error
, warning
, info
, verbose
, debug
, trace
. Default is error
.
The path to the FFmpeg binary. If not specified, the FFmpeg binary shipped with Revideo will be used.
BrowserLaunchArgumentOptions
number
The "base port" we use for the vite server. When you have three workers and a base port 5000, the vite servers created by the three workers will use port 5000, 5001, and 5002. Default is 9000.
InlineConfig
(worker: number, progress: number) => void
A function that gets called with the progress of the rendering process, can be used to report progress back to users (e.g. in a web app). The function gets called with two arguments: the id of the worker that is calling the function, and the progress of the rendering process (float between 0 and 1). Does nothing by default
The function returns a string containing the path to the rendered video.
The renderPartialVideo()
function lets you render partial videos if you want to distribute the rendering workload across multiple workers. You can find an example of this in our Cloud Functions example. To use renderPartialVideo()
, you don't have to manually assign a range of frames or timestamps to render. Instead, you just pass the worker id and the total number of workers your rendering job uses, and the function will figure out the frames to render by itself.
Since merging partial videos gives you audio issues (audio becomes laggy), this function returns the path to the audio file and mute video file of the partial video. Afterwards, you should first concatenate all of the partial audio files and then concatenate all of the partial mute video files, and then merge the full audio and video to obtain your final mp4 file.
To do this, you can use the concatenateMedia()
and mergeAudioWithVideo()
functions from @revideo/ffmpeg
.
An object of type RenderPartialVideoProps
with the following attributes:
string
A string pointing towards your Vite config file. This will probably be ./src/project.ts
.
number
The id of the worker. We start counting at 0, so if you have 5 workers, values from 0 to 4 are accepted.
number
The number of workers you use in total. This informs the function which range of the video to render. For instance, worker 0 out of 10 workers would render 1/10 of the full video, whereas worker 0 out of 2 would render half of the video.
Record<string, any>
Parameters / or variables passed to your video..
A Omit<RenderSettings, 'workers'>
object with the following properties:
string, has to end with '.mp4'
The file name of the video output
string
The output directory of the rendered video. default="./output"
[number, number]
The start and end second of the video. Can be used to only render a part of the video.
[number, number]
Dimensions of the video to render as [x,y]. Uses the value specified in project.meta
by default.
boolean
Logs render progress to the console if set to true
.
FFmpeg options - is an instance of FfmpegSettings
. These overwrite the following settings set through environment variables:
error
| warning
| info
| verbose
, debug
| trace
The log level of FFmpeg. Can be one of error
, warning
, info
, verbose
, debug
, trace
. Default is error
.
The path to the FFmpeg binary. If not specified, the FFmpeg binary shipped with Revideo will be used.
BrowserLaunchArgumentOptions
number
The "base port" we use for the vite server. When you have three workers and a base port 5000, the vite servers created by the three workers will use port 5000, 5001, and 5002. Default is 9000.
InlineConfig
(worker: number, progress: number) => void
A function that gets called with the progress of the rendering process, can be used to report progress back to users (e.g. in a web app). The function gets called with two arguments: the id of the worker that is calling the function, and the progress of the rendering process (float between 0 and 1). Does nothing by default
{ audioFile: string, videoFile: string }
Paths to the audio and video files of the partial render.
Parameters / or variables passed to your video. See learn more about parameterized videos.
outFile?
outDir?
range?
workers?
dimensions?
logProgress?
ffmpeg?
ffmpegLogLevel?
ffmpegPath?
puppeteer?
Launch options for puppeteer - is an instance of puppeteer's
viteBasePort?
viteConfig?
Configuration of the vite server used for rendering, an instance of . You can use these options to configure the server port, the cache directory, and more.
progressCallback?
outFile?
outDir?
range?
dimensions?
logProgress?
ffmpeg?
ffmpegLogLevel?
ffmpegPath?
puppeteer?
Launch options for puppeteer - is an instance of puppeteer's
viteBasePort?
viteConfig?
Configuration of the vite server used for rendering, an instance of . You can use these options to configure the server port, the cache directory, and more.
progressCallback?