1
- import { FfmpegExporterOptions , UserProjectSettings } from '@revideo/core' ;
1
+ import {
2
+ FfmpegExporterOptions ,
3
+ RenderVideoUserProjectSettings ,
4
+ } from '@revideo/core' ;
2
5
import {
3
6
FfmpegSettings ,
4
7
audioCodecs ,
@@ -15,27 +18,13 @@ import * as fs from 'fs';
15
18
import * as os from 'os' ;
16
19
import * as path from 'path' ;
17
20
import puppeteer , { Browser , PuppeteerLaunchOptions } from 'puppeteer' ;
18
- import { getParamDefaultsAndCheckValidity } from 'validate-settings' ;
21
+ import {
22
+ getParamDefaultsAndCheckValidity ,
23
+ getRenderVideoUserProjectSettingsDefault ,
24
+ } from 'validate-settings' ;
19
25
import { InlineConfig , ServerOptions , ViteDevServer , createServer } from 'vite' ;
20
26
import { rendererPlugin } from './renderer-plugin' ;
21
27
22
- /**
23
- * We pass a lot of render settings to the client side of the renderer
24
- * via the URL. This function builds the URL with the necessary parameters.
25
- */
26
- function buildUrl (
27
- port : number ,
28
- fileName : string ,
29
- workerId : number ,
30
- totalNumOfWorkers : number ,
31
- hiddenFolderId : string ,
32
- ) {
33
- const fileNameEscaped = encodeURIComponent ( fileName ) ;
34
- const hiddenFolderIdEscaped = encodeURIComponent ( hiddenFolderId ) ;
35
-
36
- return `http://localhost:${ port } /render?fileName=${ fileNameEscaped } &workerId=${ workerId } &totalNumOfWorkers=${ totalNumOfWorkers } &hiddenFolderId=${ hiddenFolderIdEscaped } ` ;
37
- }
38
-
39
28
export interface RenderSettings {
40
29
// Name of the video file (default is 'video.mp4')
41
30
outFile ?: `${string } .mp4` | `${string } .webm` | `${string } .mov`;
@@ -50,12 +39,7 @@ export interface RenderSettings {
50
39
workers ?: number ;
51
40
logProgress ?: boolean ;
52
41
53
- renderSettings : Partial < UserProjectSettings [ 'shared' ] > &
54
- Partial < Omit < UserProjectSettings [ 'rendering' ] , 'exporter' > > &
55
- Omit <
56
- UserProjectSettings [ 'rendering' ] ,
57
- 'fps' | 'resolutionScale' | 'colorSpace'
58
- > ;
42
+ projectSettings ?: RenderVideoUserProjectSettings ;
59
43
60
44
/**
61
45
* When using multiple workers, this is the port of the first worker.
@@ -74,6 +58,23 @@ export interface RenderSettings {
74
58
progressCallback ?: ( worker : number , progress : number ) => void ;
75
59
}
76
60
61
+ /**
62
+ * We pass a lot of render settings to the client side of the renderer
63
+ * via the URL. This function builds the URL with the necessary parameters.
64
+ */
65
+ function buildUrl (
66
+ port : number ,
67
+ fileName : string ,
68
+ workerId : number ,
69
+ totalNumOfWorkers : number ,
70
+ hiddenFolderId : string ,
71
+ ) {
72
+ const fileNameEscaped = encodeURIComponent ( fileName ) ;
73
+ const hiddenFolderIdEscaped = encodeURIComponent ( hiddenFolderId ) ;
74
+
75
+ return `http://localhost:${ port } /render?fileName=${ fileNameEscaped } &workerId=${ workerId } &totalNumOfWorkers=${ totalNumOfWorkers } &hiddenFolderId=${ hiddenFolderIdEscaped } ` ;
76
+ }
77
+
77
78
/**
78
79
* Starts the vite server and creates a puppeteer browser instance
79
80
*/
@@ -95,10 +96,10 @@ async function initBrowserAndServer(
95
96
plugins : [
96
97
motionCanvas ( { project : resolvedProjectPath , output : outputFolderName } ) ,
97
98
rendererPlugin (
99
+ getRenderVideoUserProjectSettingsDefault ( settings . projectSettings ) ,
98
100
variables ,
99
101
settings . ffmpeg ,
100
102
projectFile ,
101
- settings . renderSettings ,
102
103
) ,
103
104
] ,
104
105
...settings . viteConfig ,
@@ -367,20 +368,20 @@ async function cleanup(
367
368
await Promise . all ( [ ...folderCleanupPromises , ...fileCleanupPromises ] ) ;
368
369
}
369
370
370
- interface RenderVideoParams {
371
- projectFile : string ;
372
- variables ?: Record < string , unknown > ;
373
- settings ?: RenderSettings ;
374
- }
375
-
376
371
const defaultSettings : RenderSettings = {
377
- renderSettings : {
372
+ projectSettings : {
378
373
exporter : {
379
374
name : '@revideo/core/wasm' ,
380
375
} ,
381
376
} ,
382
377
} ;
383
378
379
+ interface RenderVideoParams {
380
+ projectFile : string ;
381
+ variables ?: Record < string , unknown > ;
382
+ settings ?: RenderSettings ;
383
+ }
384
+
384
385
/**
385
386
* Renders a video to a file.
386
387
* @param projectFile - Path to the project.ts file.
0 commit comments