Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
'delete segment' button
Brendan Allan224668a7b1e5
diff --git a/apps/desktop/src-tauri/src/display.rs b/apps/desktop/src-tauri/src/display.rsindex 8dc3fe1c1..a300a78ff 100644--- a/apps/desktop/src-tauri/src/display.rs+++ b/apps/desktop/src-tauri/src/display.rs@@ -1,8 +1,5 @@use ffmpeg::{format as avformat, frame::Video, software};-use std::{- path::PathBuf,- time::{Instant, SystemTime},-};+use std::path::PathBuf;use scap::{capturer::{Area, Capturer, Options, Point, Resolution, Size},@@ -195,8 +192,6 @@ pub async fn start_capturing(let mut start_time_tx = Some(tx);- let mut last_valid_frame: Option<ffmpeg::frame::Video> = None;-loop {if controller.is_stopped() {break;@@ -218,28 +213,13 @@ pub async fn start_capturing(match frame {Ok(Frame::BGRA(frame)) => {- if let Some(rgb_frame) = bgra_frame(- &frame.data,- capture_size[0],- capture_size[1],- last_valid_frame.as_ref(),- ) {- // Successfully created RGB frame- last_valid_frame = Some(rgb_frame.clone());-+ if let Some(rgb_frame) =+ bgra_frame(&frame.data, capture_size[0], capture_size[1])+ {let mut yuv_frame = Video::empty();scaler.run(&rgb_frame, &mut yuv_frame).unwrap();encoder.encode_frame(yuv_frame, frame.display_time / 1_000_000);- } else {- println!("Failed to create valid frame, using last valid frame.");- if let Some(ref last_frame) = last_valid_frame {- let mut yuv_frame = Video::empty();- scaler.run(last_frame, &mut yuv_frame).unwrap();- encoder.encode_frame(yuv_frame, frame.display_time / 1_000_000);- } else {- println!("No valid frame available to use.");- }}}_ => println!("Failed to get frame"),diff --git a/apps/desktop/src-tauri/src/encoder.rs b/apps/desktop/src-tauri/src/encoder.rsindex ddd1fd595..cd2567899 100644--- a/apps/desktop/src-tauri/src/encoder.rs+++ b/apps/desktop/src-tauri/src/encoder.rs@@ -184,21 +184,11 @@ pub fn nv12_frame(bytes: &[u8], width: u32, height: u32) -> ffmpeg::frame::Videoframe}-pub fn bgra_frame(- data: &[u8],- width: u32,- height: u32,- previous_frame: Option<&ffmpeg::frame::Video>,-) -> Option<ffmpeg::frame::Video> {+pub fn bgra_frame(data: &[u8], width: u32, height: u32) -> Option<ffmpeg::frame::Video> {let expected_size = (width as usize) * (height as usize) * 4; // 4 bytes per pixel for BGRAif data.len() != expected_size {- println!(- "Invalid frame size: expected {}, got {}",- expected_size,- data.len()- );- return previous_frame.cloned();+ return None;}let mut frame = Video::new(Pixel::BGRA, width, height);diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsxindex 89060e8be..e595d068d 100644--- a/apps/desktop/src/routes/editor/Player.tsx+++ b/apps/desktop/src/routes/editor/Player.tsx@@ -52,7 +52,7 @@ export function Player() {const splitButton = () => (<EditorButton<typeof KToggleButton>- disabled={flags.split}+ disabled={!flags.split}pressed={split()}onChange={setSplit}as={KToggleButton}diff --git a/apps/desktop/src/routes/editor/Timeline.tsx b/apps/desktop/src/routes/editor/Timeline.tsxindex 516dba657..b26c0c773 100644--- a/apps/desktop/src/routes/editor/Timeline.tsx+++ b/apps/desktop/src/routes/editor/Timeline.tsx@@ -139,11 +139,9 @@ export function Timeline() {segments[i()].end = splitTime;}));-- // console.log({ splitTime });}}>- <div class="h-full border border-white ring-1 ring-blue-300 flex flex-row rounded-xl overflow-hidden">+ <div class="h-full border border-white ring-1 ring-blue-300 flex flex-row rounded-xl overflow-hidden group"><divclass="bg-blue-300 w-[0.5rem] cursor-col-resize"onMouseDown={(downEvent) => {@@ -197,11 +195,27 @@ export function Timeline() {});}}/>- <div class="bg-blue-50 relative w-full h-full flex flex-row items-end justify-end px-[0.5rem] py-[0.25rem]">- <span class="text-black-transparent-60 text-[0.625rem]">+ <div class="bg-blue-50 relative w-full h-full flex flex-row items-center justify-between px-[0.5rem] py-[0.25rem]">+ <span class="text-black-transparent-60 text-[0.625rem] mt-auto">{formatTime(segment.start)}</span>- <span class="text-black-transparent-60 text-[0.625rem] ml-auto">+ <Show when={segments().length > 1}>+ <button+ onClick={() => {+ setProject(+ "timeline",+ "segments",+ produce((segments) => {+ segments.splice(i(), 1);+ })+ );+ }}+ class="size-7 opacity-0 group/button group-hover:opacity-100 transition-opacity bg-gray-50 rounded-full flex flex-col items-center justify-center"+ >+ <IconCapTrash class="size-4 text-gray-400 group-hover/button:text-gray-500 transition-colors" />+ </button>+ </Show>+ <span class="text-black-transparent-60 text-[0.625rem] mt-auto">{formatTime(segment.end)}</span></div>diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex 7bdbf4e9c..81170dcea 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -45,6 +45,7 @@ declare global {const IconCapShadow: typeof import('~icons/cap/shadow.jsx')['default']const IconCapSquare: typeof import('~icons/cap/square.jsx')['default']const IconCapStopCircle: typeof import('~icons/cap/stop-circle.jsx')['default']+ const IconCapTrash: typeof import('~icons/cap/trash.jsx')['default']const IconCapUndo: typeof import('~icons/cap/undo.jsx')['default']const IconCapUpload: typeof import('~icons/cap/upload.jsx')['default']const IconLucideBell: typeof import('~icons/lucide/bell.jsx')['default']