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
15 changes: 10 additions & 5 deletions electron/native/ScreenCaptureKitRecorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,17 @@ final class ScreenCaptureRecorder: NSObject, SCStreamOutput, SCStreamDelegate {
throw NSError(domain: "RecordlyCapture", code: 3, userInfo: [NSLocalizedDescriptionKey: "Window not found"])
}

filter = SCContentFilter(desktopIndependentWindow: window)

let candidateDisplay = availableContent.displays.first(where: {
$0.frame.intersects(window.frame) || $0.frame.contains(CGPoint(x: window.frame.midX, y: window.frame.midY))
})
let scaleFactor = ScreenCaptureRecorder.scaleFactor(for: candidateDisplay?.displayID ?? CGMainDisplayID())

guard let display = candidateDisplay else {
throw NSError(domain: "RecordlyCapture", code: 4, userInfo: [NSLocalizedDescriptionKey: "No intersecting display found for window"])
}

filter = SCContentFilter(display: display, including: [window], exceptingApplications: [], exceptingWindows: [])

let scaleFactor = ScreenCaptureRecorder.scaleFactor(for: display.displayID)
outputWidth = max(2, Int(window.frame.width) * scaleFactor)
outputHeight = max(2, Int(window.frame.height) * scaleFactor)
if #available(macOS 14.0, *) {
Expand Down Expand Up @@ -655,8 +660,8 @@ guard CommandLine.arguments.count >= 2 else {
}

// Force CoreGraphics Services initialization on the main thread.
// Without this, SCContentFilter(desktopIndependentWindow:) crashes with
// CGS_REQUIRE_INIT because CGS is never initialised in a CLI tool.
// Without this, CoreGraphics operations may fail with CGS_REQUIRE_INIT
// because CGS is never initialised in a CLI tool.
let _ = CGMainDisplayID()

// Pre-flight check: ensure screen recording permission is granted before
Expand Down
35 changes: 21 additions & 14 deletions src/components/video-editor/VideoPlayback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1097,20 +1097,24 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
if (!frameData) return false;

if (frameData.draw) {
// Resolution-independent: draw at a reasonable size, Pixi handles the rest
const drawW = 1920;
const drawH = 1080;
const canvas = document.createElement("canvas");
canvas.width = drawW;
canvas.height = drawH;
const ctx = canvas.getContext("2d");
if (ctx) frameData.draw(ctx, drawW, drawH);
if (cancelled || frameIdRef.current !== frame) return true;
const texture = Texture.from(canvas);
const sprite = new Sprite(texture);
frameSpriteRef.current = sprite;
container.addChild(sprite);
layoutVideoContentRef.current?.();
try {
// Resolution-independent: draw at a reasonable size, Pixi handles the rest
const drawW = 1920;
const drawH = 1080;
const canvas = document.createElement("canvas");
canvas.width = drawW;
canvas.height = drawH;
const ctx = canvas.getContext("2d");
if (ctx) frameData.draw(ctx, drawW, drawH);
if (cancelled || frameIdRef.current !== frame) return true;
const texture = Texture.from(canvas);
const sprite = new Sprite(texture);
frameSpriteRef.current = sprite;
container.addChild(sprite);
layoutVideoContentRef.current?.();
} catch (err) {
console.error(`[VideoPlayback] Failed to draw frame '${frameData.id}':`, err);
}
} else {
const img = new Image();
img.onload = () => {
Expand All @@ -1121,6 +1125,9 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
container.addChild(sprite);
layoutVideoContentRef.current?.();
};
img.onerror = (err) => {
console.error(`[VideoPlayback] Failed to load frame image from '${frameData.filePath}':`, err);
};
img.src = frameData.filePath;
}
return true;
Expand Down