Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Fix windows builds (#326)
Brendan Allandd6b7cd8157f
diff --git a/apps/cli/src/record.rs b/apps/cli/src/record.rsindex 52998fb86..40ecbc5dc 100644--- a/apps/cli/src/record.rs+++ b/apps/cli/src/record.rs@@ -76,8 +76,6 @@ impl RecordStart {capture_target: target_info,camera_label: camera.as_ref().map(|c| c.camera_info.human_name()),audio_input_name: None,- fps: 30,- output_resolution: None,},camera.map(|c| Arc::new(Mutex::new(c))),None,diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rsindex 2cf013f59..b59397129 100644--- a/apps/desktop/src-tauri/src/general_settings.rs+++ b/apps/desktop/src-tauri/src/general_settings.rs@@ -1,4 +1,3 @@-use cap_project::Resolution;use serde::{Deserialize, Serialize};use serde_json::json;use specta::Type;@@ -32,8 +31,6 @@ pub struct GeneralSettingsStore {#[serde(default)]pub theme: AppTheme,#[serde(default)]- pub recording_config: Option<RecordingConfig>,- #[serde(default)]pub commercial_license: Option<CommercialLicense>,#[serde(default)]pub last_version: Option<String>,@@ -61,7 +58,6 @@ impl Default for GeneralSettingsStore {disable_auto_open_links: false,has_completed_startup: false,theme: AppTheme::System,- recording_config: None,commercial_license: None,last_version: None,}@@ -77,25 +73,6 @@ pub enum AppTheme {Dark,}-#[derive(Debug, Clone, Serialize, Deserialize, Type)]-#[serde(rename_all = "camelCase")]-pub struct RecordingConfig {- pub fps: u32,- pub resolution: Resolution,-}--impl Default for RecordingConfig {- fn default() -> Self {- Self {- fps: 30,- resolution: Resolution {- width: 1920,- height: 1080,- },- }- }-}-fn true_b() -> bool {true}diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 5c808fc91..2bf46711a 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -37,7 +37,7 @@ use clipboard_rs::common::RustImage;use clipboard_rs::{Clipboard, ClipboardContext};use editor_window::EditorInstances;use editor_window::WindowEditorInstance;-use general_settings::{GeneralSettingsStore, RecordingConfig};+use general_settings::GeneralSettingsStore;use mp4::Mp4Reader;// use display::{list_capture_windows, Bounds, CaptureTarget, FPS};use notifications::NotificationType;@@ -59,11 +59,9 @@ use std::{process::Command,str::FromStr,sync::Arc,- time::Duration,};use tauri::Window;-use tauri::{AppHandle, Emitter, Manager, Runtime, State, WindowEvent};-use tauri_plugin_deep_link::DeepLinkExt;+use tauri::{AppHandle, Manager, State, WindowEvent};use tauri_plugin_dialog::DialogExt;use tauri_plugin_notification::{NotificationExt, PermissionState};use tauri_plugin_shell::ShellExt;@@ -404,14 +402,6 @@ async fn get_recording_options() -> Result<RecordingOptions, ()> {let mut state = state.write().await;- // Load settings from disk if they exist- if let Ok(Some(settings)) = GeneralSettingsStore::get(&app) {- if let Some(config) = settings.recording_config {- state.start_recording_options.fps = config.fps;- state.start_recording_options.output_resolution = Some(config.resolution);- }- }-// If there's a saved audio input but no feed, initialize itif let Some(audio_input_name) = state.start_recording_options.audio_input_name() {if state.audio_input_feed.is_none() {@@ -444,17 +434,6 @@ async fn set_recording_options(.set_start_recording_options(options.clone()).await?;- // Update persistent settings- GeneralSettingsStore::update(&app, |settings| {- settings.recording_config = Some(RecordingConfig {- fps: options.fps,- resolution: options.output_resolution.unwrap_or_else(|| Resolution {- width: 1920,- height: 1080,- }),- });- })?;-Ok(())}@@ -2115,8 +2094,6 @@ pub async fn run() {}),camera_label: None,audio_input_name: None,- fps: 30,- output_resolution: None,},current_recording: None,pre_created_video: None,diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex e856c936f..44e9d206c 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -59,14 +59,6 @@ pub async fn start_recording() -> Result<(), String> {let mut state = state_mtx.write().await;- // Get the recording config- let config = GeneralSettingsStore::get(&app)?- .and_then(|s| s.recording_config)- .unwrap_or_default();-- // Update the recording options with the configured FPS- state.start_recording_options.fps = config.fps;-let id = uuid::Uuid::new_v4().to_string();let recording_dir = appdiff --git a/apps/desktop/src/routes/(window-chrome)/settings.tsx b/apps/desktop/src/routes/(window-chrome)/settings.tsxindex ad0d14908..1132b2c62 100644--- a/apps/desktop/src/routes/(window-chrome)/settings.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings.tsx@@ -66,12 +66,6 @@ export default function Settings(props: RouteSectionProps) {name: "General",icon: IconCapSettings,},- {- type: "link",- href: "config",- name: "Recording Config",- icon: IconLucideVideo,- },{type: "link",href: "hotkeys",diff --git a/apps/desktop/src/routes/(window-chrome)/settings/config.tsx b/apps/desktop/src/routes/(window-chrome)/settings/config.tsxdeleted file mode 100644index 06892ee1f..000000000--- a/apps/desktop/src/routes/(window-chrome)/settings/config.tsx+++ /dev/null@@ -1,120 +0,0 @@-import { createQuery } from "@tanstack/solid-query";-import { For, Show } from "solid-js";-import { commands } from "~/utils/tauri";-import { Select as KSelect } from "@kobalte/core/select";-import { cx } from "cva";-import {- MenuItem,- MenuItemList,- PopperContent,- topLeftAnimateClasses,-} from "~/routes/editor/ui";--type ResolutionOption = {- label: string;- value: string;- width: number;- height: number;-};--type FpsOption = {- label: string;- value: number;-};--const RESOLUTION_OPTIONS: ResolutionOption[] = [- { label: "720p", value: "720p", width: 1280, height: 720 },- { label: "1080p", value: "1080p", width: 1920, height: 1080 },- { label: "4K", value: "4k", width: 3840, height: 2160 },-];--const FPS_OPTIONS: FpsOption[] = [- { label: "30 FPS", value: 30 },- { label: "60 FPS", value: 60 },-];--export default function Config() {- const config = createQuery(() => ({- queryKey: ["recording-config"],- queryFn: () => commands.getRecordingOptions(),- }));-- const updateConfig = async (updates: {- fps?: number;- outputResolution?: { width: number; height: number };- }) => {- if (!config.data) return;-- await commands.setRecordingOptions({- ...config.data,- ...updates,- });-- config.refetch();- };-- return (- <div class="flex flex-col w-full h-full divide-y divide-[--gray-200] pt-1 pb-12">- <div class="p-4">- <div class="mb-6">- <label class="text-sm font-medium mb-2 block text-gray-500 dark:text-gray-400">- Output Resolution- </label>- <KSelect<(typeof RESOLUTION_OPTIONS)[number]>- options={RESOLUTION_OPTIONS}- optionValue="value"- optionTextValue="label"- placeholder="Select Resolution"- value={RESOLUTION_OPTIONS.find(- (opt) =>- opt.width === config.data?.outputResolution?.width &&- opt.height === config.data?.outputResolution?.height- )}- onChange={(option) => {- if (option) {- updateConfig({- outputResolution: {- width: option.width,- height: option.height,- },- });- }- }}- itemComponent={(props) => (- <MenuItem<typeof KSelect.Item>- as={KSelect.Item}- item={props.item}- >- <KSelect.ItemLabel class="flex-1">- {props.item.rawValue.label}- </KSelect.ItemLabel>- </MenuItem>- )}- >- <KSelect.Trigger class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect">- <KSelect.Value<- (typeof RESOLUTION_OPTIONS)[number]- > class="flex-1 text-sm text-left truncate text-[--gray-500]">- {(state) => <span>{state.selectedOption()?.label}</span>}- </KSelect.Value>- <KSelect.Icon>- <IconCapChevronDown class="size-4 shrink-0 transform transition-transform ui-expanded:rotate-180 text-[--gray-500]" />- </KSelect.Icon>- </KSelect.Trigger>- <KSelect.Portal>- <PopperContent<typeof KSelect.Content>- as={KSelect.Content}- class={cx(topLeftAnimateClasses, "z-50")}- >- <MenuItemList<typeof KSelect.Listbox>- class="max-h-32 overflow-y-auto"- as={KSelect.Listbox}- />- </PopperContent>- </KSelect.Portal>- </KSelect>- </div>- </div>- </div>- );-}diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex 5aeaec1b3..f22ade140 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -249,7 +249,7 @@ export type Display = { path: string; fps?: number }export type EditorStateChanged = { playhead_position: number }export type ExportEstimates = { duration_seconds: number; estimated_time_seconds: number; estimated_size_mb: number }export type Flags = { recordMouseState: boolean; split: boolean }-export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; openEditorAfterRecording?: boolean; hideDockIcon?: boolean; hapticsEnabled?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; recordingConfig?: RecordingConfig | null; commercialLicense?: CommercialLicense | null; lastVersion?: string | null }+export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; openEditorAfterRecording?: boolean; hideDockIcon?: boolean; hapticsEnabled?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null }export type HapticPattern = "Alignment" | "LevelChange" | "Generic"export type HapticPerformanceTime = "Default" | "Now" | "DrawCompleted"export type Hotkey = { code: string; meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }@@ -271,11 +271,10 @@ export type Preset = { name: string; config: ProjectConfiguration }export type PresetsStore = { presets: Preset[]; default: number | null }export type ProjectConfiguration = { aspectRatio: AspectRatio | null; background: BackgroundConfiguration; camera: Camera; audio: AudioConfiguration; cursor: CursorConfiguration; hotkeys: HotkeysConfiguration; timeline?: TimelineConfiguration | null; motionBlur: number | null }export type ProjectRecordings = { segments: SegmentRecordings[] }-export type RecordingConfig = { fps: number; resolution: Resolution }export type RecordingInfo = { captureTarget: ScreenCaptureTarget }export type RecordingMeta = ({ segment: SingleSegment } | { inner: MultipleSegments }) & { pretty_name: string; sharing?: SharingMeta | null }export type RecordingMetaChanged = { id: string }-export type RecordingOptions = { captureTarget: ScreenCaptureTarget; cameraLabel: string | null; audioInputName: string | null; fps: number; outputResolution: Resolution | null }+export type RecordingOptions = { captureTarget: ScreenCaptureTarget; cameraLabel: string | null; audioInputName: string | null }export type RecordingOptionsChanged = nullexport type RecordingStarted = nullexport type RecordingStopped = { path: string }@@ -286,7 +285,6 @@ export type RequestOpenSettings = { page: string }export type RequestRestartRecording = nullexport type RequestStartRecording = nullexport type RequestStopRecording = null-export type Resolution = { width: number; height: number }export type S3UploadMeta = { id: string; user_id: string; aws_region?: string; aws_bucket?: string; aws_endpoint?: string }export type ScreenCaptureTarget = ({ variant: "window" } & CaptureWindow) | ({ variant: "screen" } & CaptureScreen) | ({ variant: "area" } & CaptureArea)export type SegmentRecordings = { display: Video; camera: Video | null; audio: Audio | null }diff --git a/crates/media/src/sources/screen_capture.rs b/crates/media/src/sources/screen_capture.rsindex b41c338c3..9207a6e69 100644--- a/crates/media/src/sources/screen_capture.rs+++ b/crates/media/src/sources/screen_capture.rs@@ -112,29 +112,10 @@ impl<TCaptureFormat> Clone for ScreenCaptureSource<TCaptureFormat> {const MAX_FPS: u32 = 60;impl<TCaptureFormat> ScreenCaptureSource<TCaptureFormat> {- pub fn init(- target: &ScreenCaptureTarget,- output_resolution: Option<cap_project::Resolution>,- output_type: Option<FrameType>,- ) -> Self {+ pub fn init(target: &ScreenCaptureTarget, output_type: Option<FrameType>) -> Self {let mut this = Self {target: target.clone(),- output_resolution: output_resolution.map(|r| {- // Choose the closest resolution based on height- if r.height <= 480 {- ScapResolution::_480p- } else if r.height <= 720 {- ScapResolution::_720p- } else if r.height <= 1080 {- ScapResolution::_1080p- } else if r.height <= 1440 {- ScapResolution::_1440p- } else if r.height <= 2160 {- ScapResolution::_2160p- } else {- ScapResolution::_4320p- }- }),+ output_resolution: None,output_type,fps: target.recording_fps(),video_info: VideoInfo::from_raw(RawVideoFormat::Bgra, 0, 0, MAX_FPS),diff --git a/crates/recording/src/actor.rs b/crates/recording/src/actor.rsindex 4c1309e7a..756afe8eb 100644--- a/crates/recording/src/actor.rs+++ b/crates/recording/src/actor.rs@@ -520,7 +520,6 @@ fn create_screen_capture({ScreenCaptureSource::<cap_media::sources::CMSampleBufferCapture>::init(&recording_options.capture_target,- recording_options.output_resolution.clone(),None,)}diff --git a/crates/recording/src/lib.rs b/crates/recording/src/lib.rsindex 76890b016..1bb618745 100644--- a/crates/recording/src/lib.rs+++ b/crates/recording/src/lib.rs@@ -4,7 +4,6 @@ pub mod cursor;pub use actor::{spawn_recording_actor, ActorHandle, CompletedRecording, RecordingError};use cap_media::sources::*;-use cap_project::Resolution;use serde::{Deserialize, Serialize};#[derive(specta::Type, Serialize, Deserialize, Clone, Debug)]@@ -13,8 +12,6 @@ pub struct RecordingOptions {pub capture_target: ScreenCaptureTarget,pub camera_label: Option<String>,pub audio_input_name: Option<String>,- pub fps: u32,- pub output_resolution: Option<Resolution>,}impl Default for RecordingOptions {@@ -27,8 +24,6 @@ impl Default for RecordingOptions {}),camera_label: None,audio_input_name: None,- fps: 30,- output_resolution: None,}}}diff --git a/crates/rendering/src/decoder/ffmpeg.rs b/crates/rendering/src/decoder/ffmpeg.rsindex aa9a7ab63..58834b642 100644--- a/crates/rendering/src/decoder/ffmpeg.rs+++ b/crates/rendering/src/decoder/ffmpeg.rs@@ -11,6 +11,7 @@ use ffmpeg::{};use ffmpeg_hw_device::{CodecContextExt, HwDevice};use ffmpeg_sys_next::{avcodec_find_decoder, AVHWDeviceType};+use tokio::sync::oneshot;use super::{pts_to_frame, DecodedFrame, VideoDecoderMessage, FRAME_CACHE_SIZE};@@ -78,6 +79,7 @@ impl FfmpegDecoder {path: PathBuf,fps: u32,rx: mpsc::Receiver<VideoDecoderMessage>,+ ready_tx: oneshot::Sender<Result<(), String>>,) {std::thread::spawn(move || {let mut input = ffmpeg::format::input(&path).unwrap();@@ -158,6 +160,8 @@ impl FfmpegDecoder {let mut packets = input.packets().peekable();+ ready_tx.send(Ok(()));+while let Ok(r) = peekable_requests.recv() {match r {VideoDecoderMessage::GetFrame(requested_time, sender) => {diff --git a/crates/rendering/src/decoder/mod.rs b/crates/rendering/src/decoder/mod.rsindex 908d9f59c..e97e94e73 100644--- a/crates/rendering/src/decoder/mod.rs+++ b/crates/rendering/src/decoder/mod.rs@@ -47,14 +47,11 @@ pub async fn spawn_decoder(let handle = AsyncVideoDecoderHandle { sender: tx };- #[cfg(target_os = "macos")]- {+ if cfg!(target_os = "macos") {+ #[cfg(target_os = "macos")]avassetreader::AVAssetReaderDecoder::spawn(name, path, fps, rx, ready_tx);- }-- #[cfg(not(target_os = "macos"))]- {- ffmpeg::FfmpegDecoder::spawn(name, path, fps, rx);+ } else {+ ffmpeg::FfmpegDecoder::spawn(name, path, fps, rx, ready_tx);}ready_rx.await.map_err(|e| e.to_string())?.map(|()| handle)