Skip to content

🎥 Make videos programmatically with React

`@remotion/compositor`: Less "no frame found" errors

Jonny Burger18e9dd23c177
diff --git a/packages/compositor-darwin-arm64/remotion b/packages/compositor-darwin-arm64/remotion
index 428be279d1..813349628f 100755
Binary files a/packages/compositor-darwin-arm64/remotion and b/packages/compositor-darwin-arm64/remotion differ
diff --git a/packages/compositor-darwin-x64/remotion b/packages/compositor-darwin-x64/remotion
index f1b62e097f..ccedac0cf4 100755
Binary files a/packages/compositor-darwin-x64/remotion and b/packages/compositor-darwin-x64/remotion differ
diff --git a/packages/compositor-linux-arm64-gnu/remotion b/packages/compositor-linux-arm64-gnu/remotion
index a458a43e27..418926f54a 100755
Binary files a/packages/compositor-linux-arm64-gnu/remotion and b/packages/compositor-linux-arm64-gnu/remotion differ
diff --git a/packages/compositor-linux-arm64-musl/remotion b/packages/compositor-linux-arm64-musl/remotion
index 737e775de6..23dcaf11d5 100755
Binary files a/packages/compositor-linux-arm64-musl/remotion and b/packages/compositor-linux-arm64-musl/remotion differ
diff --git a/packages/compositor-linux-x64-gnu/remotion b/packages/compositor-linux-x64-gnu/remotion
index 0181c959cf..d09b2ab1e9 100755
Binary files a/packages/compositor-linux-x64-gnu/remotion and b/packages/compositor-linux-x64-gnu/remotion differ
diff --git a/packages/compositor-linux-x64-musl/remotion b/packages/compositor-linux-x64-musl/remotion
index e5dc168cfd..528e181bc9 100755
Binary files a/packages/compositor-linux-x64-musl/remotion and b/packages/compositor-linux-x64-musl/remotion differ
diff --git a/packages/compositor/rust/ffmpeg.rs b/packages/compositor/rust/ffmpeg.rs
index f46f3260b4..eccb70ef9d 100644
--- a/packages/compositor/rust/ffmpeg.rs
+++ b/packages/compositor/rust/ffmpeg.rs
@@ -39,6 +39,7 @@ pub fn extract_frame(
tone_mapped,
position,
threshold - 1,
+ false,
),
Ok(None) => Ok(None),
Err(err) => return Err(err),
diff --git a/packages/compositor/rust/frame_cache.rs b/packages/compositor/rust/frame_cache.rs
index 4ce29e541b..72c3a8567b 100644
--- a/packages/compositor/rust/frame_cache.rs
+++ b/packages/compositor/rust/frame_cache.rs
@@ -199,6 +199,7 @@ impl FrameCache {
time: i64,
threshold: i64,
thread_index: usize,
+ allow_no_pts_after: bool,
) -> Result<Option<usize>, ErrorWithBacktrace> {
let mut best_item: Option<usize> = None;
let mut best_distance = std::i64::MAX;
@@ -238,7 +239,7 @@ impl FrameCache {
let has_pts_after = self.items.iter().any(|item| item.resolved_pts >= time);
// If this happens, then `last_frame` has not worked correctly. Do not match
- if !has_pts_after {
+ if !has_pts_after && !allow_no_pts_after {
return Ok(None);
}
diff --git a/packages/compositor/rust/frame_cache_manager.rs b/packages/compositor/rust/frame_cache_manager.rs
index a8357a5853..ed7e0b479a 100644
--- a/packages/compositor/rust/frame_cache_manager.rs
+++ b/packages/compositor/rust/frame_cache_manager.rs
@@ -207,12 +207,13 @@ impl FrameCacheManager {
tone_mapped: bool,
time: i64,
threshold: i64,
+ allow_no_pts_after: bool,
) -> Result<Option<usize>, ErrorWithBacktrace> {
let thread_index = self.thread_index.clone();
Ok(self
.get_frame_cache(src, original_src, transparent, tone_mapped)
.lock()?
- .get_item_id(time, threshold, thread_index)?)
+ .get_item_id(time, threshold, thread_index, allow_no_pts_after)?)
}
pub fn get_cache_item_from_id(
diff --git a/packages/compositor/rust/opened_stream.rs b/packages/compositor/rust/opened_stream.rs
index 239155799f..36d413d108 100644
--- a/packages/compositor/rust/opened_stream.rs
+++ b/packages/compositor/rust/opened_stream.rs
@@ -161,7 +161,7 @@ impl OpenedStream {
target_position: i64,
time_base: Rational,
one_frame_in_time_base: i64,
- threshold: i64,
+ _threshold: i64,
tone_mapped: bool,
frame_cache_manager: &mut FrameCacheManager,
thread_index: usize,
@@ -450,8 +450,10 @@ impl OpenedStream {
}
}
+ // Allow a lot of threshold here, because otherwise we would crash.
+ // Better to have a frame with a lot of deviation than to crash.
let final_frame = frame_cache_manager
- .get_cache_item_id(&self.src, &self.original_src, self.transparent, tone_mapped, target_position, threshold)?;
+ .get_cache_item_id(&self.src, &self.original_src, self.transparent, tone_mapped, target_position, 1000000000, true)?;
if final_frame.is_none() {
return Err(std::io::Error::new(