Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Fallback to display start time for missing segment times

Richie McIlroy7b5cc5c4fad6
diff --git a/crates/recording/src/recovery.rs b/crates/recording/src/recovery.rs
index 0a8f55415..b693fd5b3 100644
--- a/crates/recording/src/recovery.rs
+++ b/crates/recording/src/recovery.rs
@@ -790,11 +790,17 @@ impl RecoveryManager {
let system_audio_path = segment_dir.join("system_audio.ogg");
let cursor_path = segment_dir.join("cursor.json");
+ let display_start_time = original_segment.and_then(|s| s.display.start_time);
+
+ let get_start_time_or_fallback = |original_time: Option<f64>| -> Option<f64> {
+ original_time.or_else(|| display_start_time.map(|_| 0.0))
+ };
+
MultipleSegment {
display: VideoMeta {
path: RelativePathBuf::from(format!("{segment_base}/display.mp4")),
fps,
- start_time: original_segment.and_then(|s| s.display.start_time),
+ start_time: display_start_time,
device_id: original_segment.and_then(|s| s.display.device_id.clone()),
},
camera: if camera_path.exists() {
@@ -804,9 +810,11 @@ impl RecoveryManager {
.and_then(|s| s.camera.as_ref())
.map(|c| c.fps)
.unwrap_or(30),
- start_time: original_segment
- .and_then(|s| s.camera.as_ref())
- .and_then(|c| c.start_time),
+ start_time: get_start_time_or_fallback(
+ original_segment
+ .and_then(|s| s.camera.as_ref())
+ .and_then(|c| c.start_time),
+ ),
device_id: original_segment
.and_then(|s| s.camera.as_ref())
.and_then(|c| c.device_id.clone()),
@@ -817,9 +825,11 @@ impl RecoveryManager {
mic: if mic_path.exists() {
Some(AudioMeta {
path: RelativePathBuf::from(format!("{segment_base}/audio-input.ogg")),
- start_time: original_segment
- .and_then(|s| s.mic.as_ref())
- .and_then(|m| m.start_time),
+ start_time: get_start_time_or_fallback(
+ original_segment
+ .and_then(|s| s.mic.as_ref())
+ .and_then(|m| m.start_time),
+ ),
device_id: original_segment
.and_then(|s| s.mic.as_ref())
.and_then(|m| m.device_id.clone()),
@@ -830,9 +840,11 @@ impl RecoveryManager {
system_audio: if system_audio_path.exists() {
Some(AudioMeta {
path: RelativePathBuf::from(format!("{segment_base}/system_audio.ogg")),
- start_time: original_segment
- .and_then(|s| s.system_audio.as_ref())
- .and_then(|a| a.start_time),
+ start_time: get_start_time_or_fallback(
+ original_segment
+ .and_then(|s| s.system_audio.as_ref())
+ .and_then(|a| a.start_time),
+ ),
device_id: original_segment
.and_then(|s| s.system_audio.as_ref())
.and_then(|a| a.device_id.clone()),