@@ -5,22 +5,10 @@ export const settings: core.CompositionSettings = {
55} ;
66
77export async function main ( composition : core . Composition ) {
8- const font = await core . loadFont ( {
9- family : 'Geologica' ,
10- weight : '800' ,
11- } ) ;
12-
138 core . env . experimental_timeBase = 30 ;
149 core . env . experimental_canonicalTimeBase = 48_000 ;
1510
16- const sources = await Promise . all ( [
17- core . Source . from < core . VideoSource > ( '/bbb_1080p_30fps.mp4' ) ,
18- core . Source . from < core . ImageSource > ( '/lenna.png' ) ,
19- core . Source . from < core . AudioSource > ( '/harvard.MP3' ) ,
20- core . Source . from < core . CaptionSource > ( '/captions.json' ) ,
21- core . Source . from < core . AudioSource > ( '/file_example_MP3_1MG.mp3' ) ,
22- core . Source . from < core . ImageSource > ( '/parrot.jpg' )
23- ] ) ;
11+ const videoSource = await core . Source . from < core . VideoSource > ( '/bbb_1080p_30fps.mp4' ) ;
2412
2513 const CLIPS = 50 ;
2614 const videoDuration = 20 ;
@@ -36,7 +24,7 @@ export async function main(composition: core.Composition) {
3624
3725 if ( endTime > videoDuration ) continue ;
3826
39- const videoClip = new core . VideoClip ( sources [ 0 ] , {
27+ const videoClip = new core . VideoClip ( videoSource , {
4028 position : 'center' ,
4129 height : '100%' ,
4230 range : [ startTime , endTime ] ,
@@ -45,221 +33,4 @@ export async function main(composition: core.Composition) {
4533
4634 await videoLayer . add ( videoClip ) ;
4735 }
48-
49- const imageClip = new core . ImageClip ( sources [ 1 ] , {
50- position : 'center' ,
51- height : 600 ,
52- duration : 6 ,
53- effects : [
54- {
55- type : 'contrast' ,
56- value : 60 ,
57- } ,
58- {
59- type : 'sepia' ,
60- value : 100 ,
61- } ,
62- {
63- type : 'drop-shadow' ,
64- value : {
65- offsetX : - 9 ,
66- offsetY : 9 ,
67- blur : 3 ,
68- color : '#e81' ,
69- } ,
70- } ,
71- ] ,
72- animations : [
73- {
74- key : 'translateX' ,
75- frames : [
76- { time : 0 , value : - 1000 } ,
77- { time : 2 , value : 1000 } ,
78- { time : 4 , value : 0 }
79- ] ,
80- } ,
81- ]
82- } ) ;
83-
84- const imageLayer = new core . Layer ( ) ;
85- await composition . add ( imageLayer ) ;
86- await imageLayer . add ( imageClip ) ;
87-
88- const audioClip = new core . AudioClip ( sources [ 2 ] ) ;
89-
90- const audioLayer = new core . Layer ( ) ;
91- await composition . add ( audioLayer ) ;
92- await audioLayer . sequential ( ) ;
93- await audioLayer . add ( audioClip ) ;
94- await audioClip . removeSilences ( ) ;
95-
96- const captionLayer = new core . Layer ( ) ;
97- await composition . add ( captionLayer ) ;
98- const captionClip = new core . CaptionClip ( sources [ 3 ] ) ;
99- await captionLayer . add ( captionClip ) ;
100-
101- const textLayer0 = new core . Layer ( ) ;
102- await composition . add ( textLayer0 ) ;
103- await textLayer0 . add ( new core . TextClip ( {
104- text : "Basic text in \nDiffusion Studio" ,
105- align : 'center' ,
106- baseline : 'middle' ,
107- fontSize : 14 ,
108- strokes : [ {
109- width : 3 ,
110- color : '#000000' ,
111- } ] ,
112- x : '50%' ,
113- y : '15%' ,
114- rotation : 45 ,
115- } ) ) ;
116-
117- const textLayer1 = new core . Layer ( ) ;
118- await composition . add ( textLayer1 ) ;
119- await textLayer1 . add (
120- new core . TextClip ( {
121- align : 'center' ,
122- baseline : 'middle' ,
123- fontSize : 14 ,
124- x : '75%' ,
125- y : '40%' ,
126- casing : 'upper' ,
127- duration : 20 ,
128- animations : [ {
129- key : 'text' ,
130- easing : 'ease-out' ,
131- frames : [
132- { time : 0 , value : '' } ,
133- { time : 20 / 30 , value : 'Animated Text' } ,
134- ] ,
135- } ]
136- } )
137- ) ;
138-
139- const rectangleLayer = new core . Layer ( ) ;
140- await composition . add ( rectangleLayer ) ;
141- await rectangleLayer . add (
142- new core . RectangleClip ( {
143- position : 'center' ,
144- delay : 6 ,
145- duration : 4 ,
146- fill : '#FF0000' ,
147- radius : 10 ,
148- strokes : [ {
149- width : 2 ,
150- color : '#000000' ,
151- } ] ,
152- animations : [
153- {
154- key : 'x' ,
155- easing : 'ease-in-out' ,
156- frames : [
157- { time : 2.6 , value : 960 } ,
158- { time : 4 , value : 50 } ,
159- ] ,
160- } ,
161- {
162- key : 'width' ,
163- easing : 'ease-in-out' ,
164- frames : [
165- { time : 0 , value : 0 } ,
166- { time : 2 , value : 1000 } ,
167- { time : 4 , value : 60 } ,
168- ] ,
169- } ,
170- {
171- key : 'height' ,
172- easing : 'ease-in-out' ,
173- frames : [
174- { time : 0 , value : 0 } ,
175- { time : 2 , value : 700 } ,
176- { time : 4 , value : 40 } ,
177- ] ,
178- } ,
179- {
180- key : 'fill' ,
181- frames : [
182- { time : 0 , value : '#FF0000' } ,
183- { time : 4 , value : '#00FF00' } ,
184- ] ,
185- }
186- ]
187- } )
188- )
189-
190- const circleLayer = new core . Layer ( ) ;
191- await composition . add ( circleLayer ) ;
192- await circleLayer . add (
193- new core . EllipseClip ( {
194- position : 'center' ,
195- x : '70%' ,
196- fill : '#FFFF00' ,
197- radius : 90 ,
198- blendMode : 'screen' ,
199- } )
200- ) ;
201-
202- const textLayer2 = new core . Layer ( ) ;
203- await composition . add ( textLayer2 ) ;
204- await textLayer2 . add (
205- new core . TextClip ( {
206- text : `This is a Complex Text` ,
207- duration : 12 ,
208- align : 'center' ,
209- baseline : 'middle' ,
210- font,
211- casing : 'upper' ,
212- fontSize : 12 ,
213- background : {
214- borderRadius : 20 ,
215- opacity : 40 ,
216- } ,
217- strokes : [ {
218- width : 2 ,
219- color : '#000000' ,
220- } ] ,
221- y : '85%' ,
222- x : '50%' ,
223- shadows : [ {
224- opacity : 70 ,
225- blur : 7 ,
226- offsetX : 2 ,
227- offsetY : 4 ,
228- } ] ,
229- styles : [ {
230- start : 8 ,
231- style : {
232- color : '#19fa2c'
233- }
234- } ] ,
235- } )
236- )
237-
238-
239- const audioClip1 = new core . AudioClip ( sources [ 4 ] , { volume : 0.2 , duration : 20 } ) ;
240- const audioLayer1 = new core . Layer ( ) ;
241- await composition . add ( audioLayer1 ) ;
242- await audioLayer1 . add ( audioClip1 ) ;
243-
244- const imageLayer2 = new core . Layer ( ) ;
245- await composition . add ( imageLayer2 ) ;
246- await imageLayer2 . add (
247- new core . ImageClip ( sources [ 1 ] , {
248- height : 300 ,
249- delay : 2 ,
250- duration : 3 ,
251- transition : {
252- duration : 3 ,
253- type : 'dissolve' ,
254- }
255- } )
256- )
257-
258- await imageLayer2 . add (
259- new core . ImageClip ( sources [ 5 ] , {
260- height : 300 ,
261- delay : 5 ,
262- duration : 3 ,
263- } )
264- )
26536}
0 commit comments