Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async fn load_recording(
if project.timeline.is_none() {
let timeline_segments = match meta.as_ref() {
StudioRecordingMeta::SingleSegment { segment } => {
let display_path = recording_meta.path(&segment.display.path);
let display_path = segment.display.as_ref().map(|d| recording_meta.path(&d.path)).unwrap_or_default();
let duration = match Video::new(&display_path, 0.0) {
Ok(video) => video.duration,
Err(_) => 5.0,
Expand All @@ -135,7 +135,7 @@ async fn load_recording(
.iter()
.enumerate()
.filter_map(|(i, segment)| {
let display_path = recording_meta.path(&segment.display.path);
let display_path = segment.display.as_ref().map(|d| recording_meta.path(&d.path)).unwrap_or_default();
let duration = match Video::new(&display_path, 0.0) {
Ok(video) => video.duration,
Err(_) => 5.0,
Expand Down
55 changes: 35 additions & 20 deletions apps/desktop/src-tauri/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ fn full_timeline_for_segments(
.iter()
.enumerate()
.map(|(index, segment)| {
let duration = get_video_duration_secs(&segment.display.path.to_path(project_path))?;
let duration = get_video_duration_secs(&segment.display.as_ref().map(|d| d.path.clone()).unwrap_or_default().to_path(project_path))?;
Ok(TimelineSegment {
recording_clip: index as u32,
timescale: 1.0,
Expand Down Expand Up @@ -347,7 +347,10 @@ fn full_timeline_for_source_segments(
.iter()
.enumerate()
.map(|(index, segment)| {
let duration = get_source_video_duration_secs(source_meta, &segment.display)?;
let duration = get_source_video_duration_secs(
source_meta,
segment.display.as_ref().ok_or("Missing display video")?,
)?;
Ok(TimelineSegment {
recording_clip: index as u32,
timescale: 1.0,
Expand Down Expand Up @@ -593,7 +596,7 @@ fn copy_keyboard_path(
return Ok(Some(target_relative_path));
};

let Some(display_dir) = source_segment.display.path.parent() else {
let Some(display_dir) = source_segment.display.as_ref().and_then(|d| d.path.parent()) else {
return Ok(None);
};

Expand Down Expand Up @@ -870,7 +873,10 @@ fn source_timeline_segments_for_import(
let max_duration = if let Some(duration) = duration_cache.get(&source_index) {
*duration
} else {
let duration = get_source_video_duration_secs(source_meta, &source_segment.display)?;
let duration = get_source_video_duration_secs(
source_meta,
source_segment.display.as_ref().ok_or("Missing display video")?,
)?;
duration_cache.insert(source_index, duration);
duration
};
Expand Down Expand Up @@ -921,15 +927,21 @@ fn copy_source_segment(
target_relative_dir: &str,
cursor_id_map: &HashMap<String, String>,
) -> Result<MultipleSegment, String> {
let display = copy_video_meta(
&source_meta.project_path,
target_project_path,
&source_segment.display,
target_relative_dir,
"display",
true,
)?
.ok_or_else(|| "Missing display video".to_string())?;
let display = source_segment
.display
.as_ref()
.map(|d| {
copy_video_meta(
&source_meta.project_path,
target_project_path,
d,
target_relative_dir,
"display",
true,
)
})
.transpose()?
.flatten();

let camera = source_segment
.camera
Expand Down Expand Up @@ -1405,12 +1417,12 @@ pub async fn start_video_import(app: AppHandle, source_path: PathBuf) -> Result<
inner: RecordingMetaInner::Studio(Box::new(StudioRecordingMeta::MultipleSegments {
inner: MultipleSegments {
segments: vec![MultipleSegment {
display: VideoMeta {
display: Some(VideoMeta {
path: RelativePathBuf::from("content/segments/segment-0/display.mp4"),
fps: 30,
start_time: Some(0.0),
device_id: None,
},
}),
camera: None,
mic: None,
system_audio: None,
Expand All @@ -1422,6 +1434,7 @@ pub async fn start_video_import(app: AppHandle, source_path: PathBuf) -> Result<
},
})),
upload: None,
audio_only: false,
};

initial_meta
Expand Down Expand Up @@ -1498,14 +1511,14 @@ pub async fn start_video_import(app: AppHandle, source_path: PathBuf) -> Result<
StudioRecordingMeta::MultipleSegments {
inner: MultipleSegments {
segments: vec![MultipleSegment {
display: VideoMeta {
display: Some(VideoMeta {
path: RelativePathBuf::from(
"content/segments/segment-0/display.mp4",
),
fps,
start_time: Some(0.0),
device_id: None,
},
}),
camera: None,
mic: None,
system_audio,
Expand All @@ -1518,6 +1531,7 @@ pub async fn start_video_import(app: AppHandle, source_path: PathBuf) -> Result<
},
)),
upload: None,
audio_only: false,
};

if let Err(e) = meta.save_for_project() {
Expand Down Expand Up @@ -1674,12 +1688,12 @@ async fn append_mp4_to_editor_project(
};

let imported_segment = MultipleSegment {
display: VideoMeta {
display: Some(VideoMeta {
path: output_video_relative_path,
fps,
start_time: Some(0.0),
device_id: None,
},
}),
camera: None,
mic: None,
system_audio,
Expand Down Expand Up @@ -1965,7 +1979,7 @@ pub async fn start_image_import(app: AppHandle, source_path: PathBuf) -> Result<
};

let segment = SingleSegment {
display: video_meta,
display: Some(video_meta),
camera: None,
audio: None,
cursor: None,
Expand All @@ -1978,6 +1992,7 @@ pub async fn start_image_import(app: AppHandle, source_path: PathBuf) -> Result<
sharing: None,
inner: RecordingMetaInner::Studio(Box::new(StudioRecordingMeta::SingleSegment { segment })),
upload: None,
audio_only: false,
};

meta.save_for_project()
Expand Down
6 changes: 4 additions & 2 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,7 @@ enum CurrentRecordingTarget {
bounds: LogicalBounds,
},
Camera,
Audio,
}

#[derive(Serialize, Type)]
Expand Down Expand Up @@ -2278,6 +2279,7 @@ async fn get_current_recording(
bounds: *bounds,
},
ScreenCaptureTarget::CameraOnly => CurrentRecordingTarget::Camera,
ScreenCaptureTarget::AudioOnly => CurrentRecordingTarget::Audio,
};

Ok(JsonValue::new(&Some(CurrentRecording {
Expand Down Expand Up @@ -2906,12 +2908,12 @@ async fn get_video_metadata(path: PathBuf) -> Result<VideoRecordingMetadata, Str

match &**meta {
StudioRecordingMeta::SingleSegment { segment } => {
vec![recording_meta.path(&segment.display.path)]
vec![recording_meta.path(&segment.display.as_ref().map(|d| d.path.clone()).unwrap_or_default())]
}
StudioRecordingMeta::MultipleSegments { inner } => inner
.segments
.iter()
.map(|s| recording_meta.path(&s.display.path))
.map(|s| recording_meta.path(&s.display.as_ref().map(|d| d.path.clone()).unwrap_or_default()))
.collect(),
}
}
Expand Down
32 changes: 21 additions & 11 deletions apps/desktop/src-tauri/src/recording.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,10 @@ pub async fn start_recording(
}

let mut inputs = inputs;
if matches!(inputs.capture_target, ScreenCaptureTarget::CameraOnly) {
if matches!(
inputs.capture_target,
ScreenCaptureTarget::CameraOnly | ScreenCaptureTarget::AudioOnly
) {
inputs.capture_system_audio = false;

{
Expand Down Expand Up @@ -1287,8 +1290,10 @@ pub async fn start_recording(
RecordingMode::Instant => {
match AuthStore::get(&app).ok().flatten() {
Some(_) => {
let upload_mode =
if matches!(inputs.capture_target, ScreenCaptureTarget::CameraOnly) {
let upload_mode = if matches!(
inputs.capture_target,
ScreenCaptureTarget::CameraOnly | ScreenCaptureTarget::AudioOnly
) {
"desktopMP4"
} else {
"desktopSegments"
Expand Down Expand Up @@ -1361,6 +1366,7 @@ pub async fn start_recording(
},
sharing: None,
upload: None,
audio_only: matches!(inputs.capture_target, ScreenCaptureTarget::AudioOnly),
};

meta.save_for_project()
Expand Down Expand Up @@ -1468,7 +1474,7 @@ pub async fn start_recording(

#[cfg(target_os = "macos")]
let mut shareable_content = match inputs.capture_target {
ScreenCaptureTarget::CameraOnly => None,
ScreenCaptureTarget::CameraOnly | ScreenCaptureTarget::AudioOnly => None,
_ => Some(acquire_shareable_content_for_target(&inputs.capture_target).await?),
};

Expand Down Expand Up @@ -2445,7 +2451,7 @@ pub async fn take_screenshot(
};

let segment = cap_project::SingleSegment {
display: video_meta,
display: Some(video_meta),
camera: None,
audio: None,
cursor: None,
Expand All @@ -2460,6 +2466,7 @@ pub async fn take_screenshot(
cap_project::StudioRecordingMeta::SingleSegment { segment },
)),
upload: None,
audio_only: false,
};

meta.save_for_project()
Expand Down Expand Up @@ -2784,10 +2791,10 @@ async fn handle_recording_finish(

let display_output_path = match &updated_studio_meta {
StudioRecordingMeta::SingleSegment { segment } => {
segment.display.path.to_path(&recording_dir)
segment.display.as_ref().map(|d| d.path.clone()).unwrap_or_default().to_path(&recording_dir)
}
StudioRecordingMeta::MultipleSegments { inner, .. } => {
inner.segments[0].display.path.to_path(&recording_dir)
inner.segments[0].display.as_ref().map(|d| d.path.clone()).unwrap_or_default().to_path(&recording_dir)
}
};

Expand Down Expand Up @@ -3028,10 +3035,10 @@ async fn finalize_studio_recording(

let display_output_path = match &updated_studio_meta {
StudioRecordingMeta::SingleSegment { segment } => {
segment.display.path.to_path(&recording_dir)
segment.display.as_ref().map(|d| d.path.clone()).unwrap_or_default().to_path(&recording_dir)
}
StudioRecordingMeta::MultipleSegments { inner, .. } => {
inner.segments[0].display.path.to_path(&recording_dir)
inner.segments[0].display.as_ref().map(|d| d.path.clone()).unwrap_or_default().to_path(&recording_dir)
}
};

Expand Down Expand Up @@ -3159,6 +3166,7 @@ pub fn generate_zoom_segments_from_clicks(
sharing: None,
inner: RecordingMetaInner::Studio(Box::new(recording.meta.clone())),
upload: None,
audio_only: false,
};

generate_zoom_segments_for_project(&recording_meta, recordings)
Expand Down Expand Up @@ -3357,7 +3365,9 @@ pub fn needs_fragment_remux(recording_dir: &Path, meta: &StudioRecordingMeta) ->
};

for segment in &inner.segments {
let display_path = segment.display.path.to_path(recording_dir);
let Some(display_path) = segment.display.as_ref().map(|d| d.path.to_path(recording_dir)) else {
continue;
};
if display_path.is_dir() {
return true;
}
Comment thread
ManthanNimodiya marked this conversation as resolved.
Expand Down Expand Up @@ -3410,7 +3420,7 @@ pub fn remux_fragmented_recording_with_trigger(
inner
.segments
.iter()
.filter_map(|seg| seg.display.start_time)
.filter_map(|seg| seg.display.as_ref().and_then(|d| d.start_time))
.fold(0.0_f64, |acc, v| acc.max(v)),
),
StudioRecordingMeta::SingleSegment { .. } => None,
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/src/recording_telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub fn target_kind_label(
ScreenCaptureTarget::Window { .. } => "window",
ScreenCaptureTarget::Area { .. } => "area",
ScreenCaptureTarget::CameraOnly => "camera_only",
ScreenCaptureTarget::AudioOnly => "audio_only",
}
}

Expand Down
6 changes: 4 additions & 2 deletions apps/desktop/src-tauri/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ pub async fn recover_recording(app: AppHandle, project_path: String) -> Result<S

let display_output_path = match &recovered.meta {
StudioRecordingMeta::SingleSegment { segment } => {
segment.display.path.to_path(&recovered.project_path)
segment.display.as_ref().map(|d| d.path.clone()).unwrap_or_default().to_path(&recovered.project_path)
}
StudioRecordingMeta::MultipleSegments { inner, .. } => inner.segments[0]
.display
.path
.as_ref()
.map(|d| d.path.clone())
.unwrap_or_default()
.to_path(&recovered.project_path),
};

Expand Down
6 changes: 4 additions & 2 deletions apps/desktop/src-tauri/src/screenshot_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl ScreenshotEditorInstances {
device_id: None,
};
let segment = SingleSegment {
display: video_meta.clone(),
display: Some(video_meta.clone()),
camera: None,
audio: None,
cursor: None,
Expand All @@ -241,6 +241,7 @@ impl ScreenshotEditorInstances {
sharing: None,
inner: RecordingMetaInner::Studio(Box::new(studio_meta.clone())),
upload: None,
audio_only: false,
}
};

Expand Down Expand Up @@ -1252,7 +1253,7 @@ pub async fn render_screenshot_png(instance: &ScreenshotEditorInstance) -> Resul
device_id: None,
};
let segment = SingleSegment {
display: video_meta.clone(),
display: Some(video_meta.clone()),
camera: None,
audio: None,
cursor: None,
Expand All @@ -1265,6 +1266,7 @@ pub async fn render_screenshot_png(instance: &ScreenshotEditorInstance) -> Resul
sharing: None,
inner: RecordingMetaInner::Studio(Box::new(studio_meta)),
upload: None,
audio_only: false,
}
};

Expand Down
4 changes: 2 additions & 2 deletions crates/editor/examples/editor-playback-benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ async fn load_recording(
if project.timeline.is_none() {
let timeline_segments = match meta.as_ref() {
StudioRecordingMeta::SingleSegment { segment } => {
let display_path = recording_meta.path(&segment.display.path);
let display_path = segment.display.as_ref().map(|d| recording_meta.path(&d.path)).unwrap_or_default();
let duration = match Video::new(&display_path, 0.0) {
Ok(video) => video.duration,
Err(_) => 5.0,
Expand All @@ -332,7 +332,7 @@ async fn load_recording(
.iter()
.enumerate()
.filter_map(|(i, segment)| {
let display_path = recording_meta.path(&segment.display.path);
let display_path = segment.display.as_ref().map(|d| recording_meta.path(&d.path)).unwrap_or_default();
let duration = match Video::new(&display_path, 0.0) {
Ok(video) => video.duration,
Err(_) => 5.0,
Expand Down
Loading
Loading