Skip to content

🎥 Make videos programmatically with React

also use minimum

Jonny Burgere367c5db5615
diff --git a/packages/renderer/rust/ffmpeg.rs b/packages/renderer/rust/ffmpeg.rs
index 2728e049f8..2bd1c78e62 100644
--- a/packages/renderer/rust/ffmpeg.rs
+++ b/packages/renderer/rust/ffmpeg.rs
@@ -51,6 +51,7 @@ pub fn extract_frame(src: String, time: f64, transparent: bool) -> Result<Vec<u8
// Seeking too far back in a stream is not efficient, rather open a new stream
// 15 seconds was chosen arbitrarily
let max_stream_position = calc_position(time + 15.0, vid.time_base);
+ let min_stream_position = calc_position(time - 15.0, vid.time_base);
for i in 0..open_stream_count {
let stream = vid.opened_streams[i].lock().unwrap();
if stream.reached_eof {
@@ -62,6 +63,9 @@ pub fn extract_frame(src: String, time: f64, transparent: bool) -> Result<Vec<u8
if stream.last_position.resolved_pts > max_stream_position {
continue;
}
+ if stream.last_position.resolved_pts < min_stream_position {
+ continue;
+ }
suitable_open_stream = Some(i);
break;