@@ -10,6 +10,13 @@ use compositor_render::{event_handler::subscribe, Resolution};
10
10
use generate:: compositor_instance:: CompositorInstance ;
11
11
use serde_json:: json;
12
12
13
+ struct SceneStyle {
14
+ timer_font_size : u32 ,
15
+ timer_bottom : u32 ,
16
+ timer_right : u32 ,
17
+ title_font_size : u32 ,
18
+ }
19
+
13
20
fn main ( ) {
14
21
let _ = fs:: remove_dir_all ( workingdir ( ) ) ;
15
22
fs:: create_dir_all ( workingdir ( ) ) . unwrap ( ) ;
@@ -21,6 +28,12 @@ fn main() {
21
28
height : 1080 ,
22
29
} ,
23
30
"1920x1080" ,
31
+ SceneStyle {
32
+ timer_font_size : 90 ,
33
+ timer_bottom : 100 ,
34
+ timer_right : 100 ,
35
+ title_font_size : 250 ,
36
+ } ,
24
37
) ;
25
38
26
39
generate_video_series (
@@ -30,6 +43,12 @@ fn main() {
30
43
height : 1920 ,
31
44
} ,
32
45
"1080x1920" ,
46
+ SceneStyle {
47
+ timer_font_size : 90 ,
48
+ timer_bottom : 100 ,
49
+ timer_right : 100 ,
50
+ title_font_size : 250 ,
51
+ } ,
33
52
) ;
34
53
35
54
generate_video_series (
@@ -39,6 +58,12 @@ fn main() {
39
58
height : 480 ,
40
59
} ,
41
60
"854x480" ,
61
+ SceneStyle {
62
+ timer_font_size : 45 ,
63
+ timer_bottom : 50 ,
64
+ timer_right : 50 ,
65
+ title_font_size : 125 ,
66
+ } ,
42
67
) ;
43
68
44
69
generate_video_series (
@@ -48,6 +73,12 @@ fn main() {
48
73
height : 854 ,
49
74
} ,
50
75
"480x854" ,
76
+ SceneStyle {
77
+ timer_font_size : 45 ,
78
+ timer_bottom : 50 ,
79
+ timer_right : 50 ,
80
+ title_font_size : 125 ,
81
+ } ,
51
82
) ;
52
83
53
84
generate_video_series (
@@ -57,6 +88,12 @@ fn main() {
57
88
height : 1080 ,
58
89
} ,
59
90
"1440x1080" ,
91
+ SceneStyle {
92
+ timer_font_size : 90 ,
93
+ timer_bottom : 100 ,
94
+ timer_right : 100 ,
95
+ title_font_size : 250 ,
96
+ } ,
60
97
) ;
61
98
62
99
generate_video_series (
@@ -66,17 +103,29 @@ fn main() {
66
103
height : 1440 ,
67
104
} ,
68
105
"1080x1440" ,
106
+ SceneStyle {
107
+ timer_font_size : 90 ,
108
+ timer_bottom : 100 ,
109
+ timer_right : 100 ,
110
+ title_font_size : 250 ,
111
+ } ,
69
112
) ;
70
113
}
71
114
72
- fn generate_video_series ( duration : Duration , resolution : Resolution , name_suffix : & str ) {
115
+ fn generate_video_series (
116
+ duration : Duration ,
117
+ resolution : Resolution ,
118
+ name_suffix : & str ,
119
+ scene_style : SceneStyle ,
120
+ ) {
73
121
// HSV 240°, 50%, 65% (dark blue)
74
122
generate_video (
75
123
workingdir ( ) . join ( format ! ( "input_1_{}.mp4" , name_suffix) ) ,
76
124
"Input 1" ,
77
125
"#5353a6ff" ,
78
126
duration,
79
127
& resolution,
128
+ & scene_style,
80
129
)
81
130
. unwrap ( ) ;
82
131
// HSV 120°, 50%, 65% (green)
@@ -86,6 +135,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
86
135
"#53a653ff" ,
87
136
duration,
88
137
& resolution,
138
+ & scene_style,
89
139
)
90
140
. unwrap ( ) ;
91
141
// HSV 0°, 50%, 65% (red)
@@ -95,6 +145,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
95
145
"#a65353ff" ,
96
146
duration,
97
147
& resolution,
148
+ & scene_style,
98
149
)
99
150
. unwrap ( ) ;
100
151
// HSV 60°, 50%, 65% (yellow)
@@ -104,6 +155,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
104
155
"#a6a653ff" ,
105
156
duration,
106
157
& resolution,
158
+ & scene_style,
107
159
)
108
160
. unwrap ( ) ;
109
161
// HSV 180°, 50%, 65% (light blue)
@@ -113,6 +165,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
113
165
"#53a6a6ff" ,
114
166
duration,
115
167
& resolution,
168
+ & scene_style,
116
169
)
117
170
. unwrap ( ) ;
118
171
// HSV 300°, 50%, 65% (purple)
@@ -122,6 +175,7 @@ fn generate_video_series(duration: Duration, resolution: Resolution, name_suffix
122
175
"#a653a6ff" ,
123
176
duration,
124
177
& resolution,
178
+ & scene_style,
125
179
)
126
180
. unwrap ( ) ;
127
181
}
@@ -138,6 +192,7 @@ fn generate_video(
138
192
rgba_color : & str ,
139
193
duration : Duration ,
140
194
resolution : & Resolution ,
195
+ scene_style : & SceneStyle ,
141
196
) -> Result < ( ) > {
142
197
let instance = CompositorInstance :: start ( ) ;
143
198
@@ -158,7 +213,7 @@ fn generate_video(
158
213
"crf" : "32"
159
214
}
160
215
} ,
161
- "initial" : scene( text, rgba_color, resolution, Duration :: ZERO )
216
+ "initial" : scene( text, rgba_color, resolution, Duration :: ZERO , scene_style )
162
217
} ,
163
218
} ) ,
164
219
) ?;
@@ -176,7 +231,7 @@ fn generate_video(
176
231
instance. send_request (
177
232
"output/output_1/update" ,
178
233
json ! ( {
179
- "video" : scene( text, rgba_color, resolution, pts) ,
234
+ "video" : scene( text, rgba_color, resolution, pts, scene_style ) ,
180
235
"schedule_time_ms" : pts. as_millis( ) ,
181
236
} ) ,
182
237
) ?;
@@ -205,6 +260,7 @@ fn scene(
205
260
rgba_color : & str ,
206
261
resolution : & Resolution ,
207
262
pts : Duration ,
263
+ style : & SceneStyle ,
208
264
) -> serde_json:: Value {
209
265
json ! ( {
210
266
"root" : {
@@ -216,24 +272,24 @@ fn scene(
216
272
{
217
273
"type" : "text" ,
218
274
"text" : text,
219
- "font_size" : resolution . width / 8 ,
275
+ "font_size" : style . title_font_size ,
220
276
"width" : resolution. width,
221
277
"align" : "center" ,
222
278
"font_family" : "Comic Sans MS" ,
223
279
} ,
224
280
{ "type" : "view" } ,
225
281
{
226
282
"type" : "view" ,
227
- "bottom" : resolution . height / 6 ,
228
- "right" : resolution . width / 8 ,
229
- "width" : resolution. width / 6 ,
230
- "height" : resolution . height / 6 ,
283
+ "bottom" : style . timer_bottom ,
284
+ "right" : style . timer_right ,
285
+ "width" : resolution. width / 2 ,
286
+ "height" : style . timer_font_size ,
231
287
"children" : [
232
288
{
233
289
"type" : "text" ,
234
290
"text" : format!( "{:.2}s" , pts. as_millis( ) as f32 / 1000.0 ) ,
235
- "font_size" : resolution . width / 16 ,
236
- "width" : resolution. width / 6 ,
291
+ "font_size" : style . timer_font_size ,
292
+ "width" : resolution. width / 2 ,
237
293
"align" : "right" ,
238
294
"font_family" : "Comic Sans MS" ,
239
295
} ,
0 commit comments