sreepathi-ravikumar commited on
Commit
27c1b80
·
verified ·
1 Parent(s): a15157a

Update rust_highlight/src/lib.rs

Browse files
Files changed (1) hide show
  1. rust_highlight/src/lib.rs +8 -6
rust_highlight/src/lib.rs CHANGED
@@ -15,13 +15,15 @@ fn render_video(
15
  let mut vf = String::new();
16
  let n = words.len() as f64;
17
  for (i, (_, (x, y, w, h))) in words.iter().enumerate() {
18
- let start = (i as f64) * (duration.parse::<f64>().unwrap() / n);
19
- let end = start + (duration.parse::<f64>().unwrap() / n);
 
 
20
  vf.push_str(&format!(
21
- "drawbox=x={}:y={}:w={}:h={}:color=yellow@0.5:enable='between(t,{:.3},{:.3})',",
22
- x, y, w, h, start, end
23
- ));
24
- }
25
  vf = vf.trim_end_matches(',').to_string();
26
 
27
  let status = Command::new("ffmpeg")
 
15
  let mut vf = String::new();
16
  let n = words.len() as f64;
17
  for (i, (_, (x, y, w, h))) in words.iter().enumerate() {
18
+ let word_duration = duration.parse::<f64>().unwrap() / n;
19
+ let start = (i as f64) * word_duration;
20
+ let end = start + word_duration;
21
+
22
  vf.push_str(&format!(
23
+ "drawbox=x={}:y={}:w={}:h={}:color=yellow@0.0:t=fill:enable='between(t,{:.3},{:.3})',",
24
+ x, y, w, h, start, end
25
+ ));
26
+ }
27
  vf = vf.trim_end_matches(',').to_string();
28
 
29
  let status = Command::new("ffmpeg")