Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(export): reject an empty timeline and a 0 fps MOV export instead of writing an empty file

Richie McIlroy4eab8490991e
diff --git a/crates/export/src/lib.rs b/crates/export/src/lib.rs
index 0547f2dd0..c4de712da 100644
--- a/crates/export/src/lib.rs
+++ b/crates/export/src/lib.rs
@@ -59,6 +59,8 @@ pub enum ExporterBuildError {
MediaLoad(String),
#[error("IO error at path '{0}': {1}")]
IO(PathBuf, std::io::Error),
+ #[error("There is nothing to export: the timeline is empty")]
+ NothingToExport,
}
pub struct ExporterBuilder {
@@ -151,6 +153,12 @@ impl ExporterBuilder {
.collect::<Vec<_>>(),
);
+ let duration =
+ cap_rendering::get_duration(&recordings, &recording_meta, studio_meta, &project_config);
+ if duration.is_nan() || duration <= 0.0 {
+ return Err(Error::NothingToExport);
+ }
+
let output_path = self
.output_path
.unwrap_or_else(|| recording_meta.output_path());
diff --git a/crates/export/src/mov.rs b/crates/export/src/mov.rs
index 71b67843a..a71d1da8a 100644
--- a/crates/export/src/mov.rs
+++ b/crates/export/src/mov.rs
@@ -57,6 +57,9 @@ impl MovExportSettings {
base: ExporterBase,
mut on_progress: impl FnMut(u32) -> bool + Send + 'static,
) -> Result<PathBuf, String> {
+ if self.fps == 0 {
+ return Err("Export frame rate must be at least 1 fps".to_string());
+ }
let meta = &base.studio_meta;
let (tx_image_data, mut video_rx) = tokio::sync::mpsc::channel::<(RenderedFrame, u32)>(4);