Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Update system diagnostics types and improve buffer handling

Richie McIlroy1ff7b055fd5c
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index 924ebae5d..9c3595635 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -372,6 +372,7 @@ uploadProgressEvent: "upload-progress-event"
/** user-defined types **/
+export type AllGpusInfo = { gpus: GpuInfoDiag[]; primaryGpuIndex: number | null; isMultiGpuSystem: boolean; hasDiscreteGpu: boolean }
export type Annotation = { id: string; type: AnnotationType; x: number; y: number; width: number; height: number; strokeColor: string; strokeWidth: number; fillColor: string; opacity: number; rotation: number; text: string | null; maskType?: MaskType | null; maskLevel?: number | null }
export type AnnotationType = "arrow" | "circle" | "rectangle" | "text" | "mask"
export type AppTheme = "system" | "light" | "dark"
@@ -441,6 +442,7 @@ quality: number | null;
* Whether to prioritize speed over quality (default: false)
*/
fast: boolean | null }
+export type GpuInfoDiag = { vendor: string; description: string; dedicatedVideoMemoryMb: number; adapterIndex: number; isSoftwareAdapter: boolean; isBasicRenderDriver: boolean; supportsHardwareEncoding: boolean }
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 }
@@ -453,7 +455,6 @@ export type JsonValue<T> = [T]
export type LogicalBounds = { position: LogicalPosition; size: LogicalSize }
export type LogicalPosition = { x: number; y: number }
export type LogicalSize = { width: number; height: number }
-export type MacOSVersionInfo = { displayName: string }
export type MainWindowRecordingStartBehaviour = "close" | "minimise"
export type MaskKeyframes = { position?: MaskVectorKeyframe[]; size?: MaskVectorKeyframe[]; intensity?: MaskScalarKeyframe[] }
export type MaskKind = "sensitive" | "highlight"
@@ -496,6 +497,7 @@ export type RecordingStatus = "pending" | "recording"
export type RecordingStopped = null
export type RecordingTargetMode = "display" | "window" | "area"
export type RenderFrameEvent = { frame_number: number; fps: number; resolution_base: XY<number> }
+export type RenderingStatus = { isUsingSoftwareRendering: boolean; isUsingBasicRenderDriver: boolean; hardwareEncodingAvailable: boolean; warningMessage: string | null }
export type RequestOpenRecordingPicker = { target_mode: RecordingTargetMode | null }
export type RequestOpenSettings = { page: string }
export type RequestScreenCapturePrewarm = { force?: boolean }
@@ -516,7 +518,7 @@ export type StartRecordingInputs = { capture_target: ScreenCaptureTarget; captur
export type StereoMode = "stereo" | "monoL" | "monoR"
export type StudioRecordingMeta = { segment: SingleSegment } | { inner: MultipleSegments }
export type StudioRecordingStatus = { status: "InProgress" } | { status: "NeedsRemux" } | { status: "Failed"; error: string } | { status: "Complete" }
-export type SystemDiagnostics = { macosVersion: MacOSVersionInfo | null; availableEncoders: string[]; screenCaptureSupported: boolean }
+export type SystemDiagnostics = { windowsVersion: WindowsVersionInfo | null; gpuInfo: GpuInfoDiag | null; allGpus: AllGpusInfo | null; renderingStatus: RenderingStatus; availableEncoders: string[]; graphicsCaptureSupported: boolean; d3D11VideoProcessorAvailable: boolean }
export type TargetUnderCursor = { display_id: DisplayId | null; window: WindowUnderCursor | null }
export type TextSegment = { start: number; end: number; enabled?: boolean; content?: string; center?: XY<number>; size?: XY<number>; fontFamily?: string; fontSize?: number; fontWeight?: number; italic?: boolean; color?: string; fadeDuration?: number }
export type TimelineConfiguration = { segments: TimelineSegment[]; zoomSegments: ZoomSegment[]; sceneSegments?: SceneSegment[]; maskSegments?: MaskSegment[]; textSegments?: TextSegment[] }
@@ -533,6 +535,7 @@ export type VideoUploadInfo = { id: string; link: string; config: S3UploadMeta }
export type WindowExclusion = { bundleIdentifier?: string | null; ownerName?: string | null; windowTitle?: string | null }
export type WindowId = string
export type WindowUnderCursor = { id: WindowId; app_name: string; bounds: LogicalBounds }
+export type WindowsVersionInfo = { major: number; minor: number; build: number; displayName: string; meetsRequirements: boolean; isWindows11: boolean }
export type XY<T> = { x: T; y: T }
export type ZoomMode = "auto" | { manual: { x: number; y: number } }
export type ZoomSegment = { start: number; end: number; amount: number; mode: ZoomMode }
diff --git a/crates/recording/src/output_pipeline/win.rs b/crates/recording/src/output_pipeline/win.rs
index d2cf3669f..71d5a127c 100644
--- a/crates/recording/src/output_pipeline/win.rs
+++ b/crates/recording/src/output_pipeline/win.rs
@@ -468,7 +468,6 @@ impl Muxer for WindowsMuxer {
let mut last_ffmpeg_frame: Option<ffmpeg::frame::Video> = None;
let mut first_timestamp: Option<Duration> = None;
let mut last_timestamp: Option<Duration> = None;
- let mut frame_count: u64 = 0;
use scap_ffmpeg::AsFFmpeg;
@@ -514,7 +513,6 @@ impl Muxer for WindowsMuxer {
};
let normalized_ts = normalize_timestamp(ts, &mut first_timestamp);
- frame_count += 1;
let Ok(mut output) = output.lock() else {
continue;
@@ -1527,7 +1525,7 @@ fn flip_buffer_size(
PixelFormat::ARGB | PixelFormat::RGB32 => width * 4 * height,
PixelFormat::RGB24 | PixelFormat::BGR24 => width * 3 * height,
PixelFormat::GRAY8 => width * height,
- PixelFormat::MJPEG => 0,
+ PixelFormat::MJPEG | PixelFormat::H264 => 0,
}
}
@@ -1626,7 +1624,7 @@ fn flip_camera_buffer_into(
PixelFormat::GRAY8 => {
flip_rows_into(data, dst, width, height);
}
- PixelFormat::MJPEG => {
+ PixelFormat::MJPEG | PixelFormat::H264 => {
let copy_len = data.len().min(dst.len());
dst[..copy_len].copy_from_slice(&data[..copy_len]);
}
@@ -1690,18 +1688,29 @@ pub fn upload_mf_buffer_to_texture(
}
(true, true) => {
let uyvy_size = (frame.width * frame.height * 2) as usize;
- let uyvy_dst = buffers.ensure_uyvy_capacity(uyvy_size);
- convert_uyvy_to_yuyv_into(original_data, uyvy_dst, frame.width, frame.height);
-
let flip_size = flip_buffer_size(
frame.width as usize,
frame.height as usize,
frame.pixel_format,
);
- let flip_dst = buffers.ensure_flip_capacity(flip_size);
+
+ if buffers.uyvy_buffer.len() < uyvy_size {
+ buffers.uyvy_buffer.resize(uyvy_size, 0);
+ }
+ if buffers.flip_buffer.len() < flip_size {
+ buffers.flip_buffer.resize(flip_size, 0);
+ }
+
+ convert_uyvy_to_yuyv_into(
+ original_data,
+ &mut buffers.uyvy_buffer[..uyvy_size],
+ frame.width,
+ frame.height,
+ );
+
flip_camera_buffer_into(
&buffers.uyvy_buffer[..uyvy_size],
- flip_dst,
+ &mut buffers.flip_buffer[..flip_size],
frame.width as usize,
frame.height as usize,
frame.pixel_format,