Skip to content

Conversation

@Brendonovich
Copy link
Contributor

@Brendonovich Brendonovich commented Aug 12, 2025

Adds a few framework-specific crates for rebuilding Scap on top of:

  • scap-screencapturekit for macOS
  • scap-direct3d for Windows (D3D11 and probably older versions i need to investigate)
  • scap-ffmpeg for maximum efficiency conversions from native buffers to ffmpeg::frame::Video

All these crates focus on providing as much native access as possible with minimal data copying.
Much of the windows code has been adapted from https://github.com/NiiightmareXD/windows-capture

Summary by CodeRabbit

  • New Features

    • Introduced cross-platform screen capture: Windows (Direct3D) and macOS (ScreenCaptureKit).
    • Added FFmpeg conversion for captured frames, enabling easy video pipeline integration.
    • Provided configurable capture settings (e.g., FPS, cursor/border visibility) and simple builder-based APIs.
    • Included example CLI tools demonstrating capture and conversion workflows.
  • Chores

    • Centralized dependency versions across the workspace (including async and platform libraries).
    • Adjusted CI to make linting non-blocking.
  • Documentation

    • Added a README for the macOS capture module.
  • Style

    • Minor whitespace cleanup.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces two new screen capture crates (scap-direct3d for Windows, scap-screencapturekit for macOS) and a cross-platform FFmpeg bridge (scap-ffmpeg) with examples. Centralizes futures via workspace. Adjusts Windows dependencies to workspace/targets. Makes Biome lint non-blocking. Minor manifest tweaks and whitespace edits.

Changes

Cohort / File(s) Summary
CI workflow
.github/workflows/ci.yml
Make Biome lint step non-failing by appending `
Workspace dependency: futures
Cargo.toml, apps/desktop/src-tauri/Cargo.toml, crates/editor/Cargo.toml, crates/export/Cargo.toml, crates/media/Cargo.toml, crates/recording/Cargo.toml, crates/rendering/Cargo.toml, crates/rendering-skia/Cargo.toml
Add workspace-level futures = "0.3.31" and switch member crates to futures = { workspace = true }.
Windows deps consolidation
crates/camera-directshow/Cargo.toml, crates/camera-mediafoundation/Cargo.toml
Move windows/windows-core to workspace and target-specific blocks; remove non-target global refs.
Camera manifest tweak
crates/camera/Cargo.toml
Adjust macOS backend dependency alias entry (name change; path unchanged).
Whitespace
crates/camera-directshow/examples/cli.rs
Remove a single blank line; no functional changes.
New crate: scap-direct3d (Windows capture)
crates/scap-direct3d/Cargo.toml, crates/scap-direct3d/src/lib.rs, crates/scap-direct3d/examples/cli.rs
Add Windows Graphics Capture/D3D11 capturer API (Display, Settings, Capturer, Frame…), example CLI, and Windows target deps.
New crate: scap-ffmpeg (FFmpeg bridge)
crates/scap-ffmpeg/Cargo.toml, crates/scap-ffmpeg/src/lib.rs, crates/scap-ffmpeg/src/direct3d.rs, crates/scap-ffmpeg/src/screencapturekit.rs, crates/scap-ffmpeg/examples/cli.rs
Add AsFFmpeg trait; implement frame conversion for Windows (RGBA) and macOS (NV12/BGRA); provide cross-platform example.
New crate: scap-screencapturekit (macOS capture)
crates/scap-screencapturekit/Cargo.toml, crates/scap-screencapturekit/README.md, crates/scap-screencapturekit/src/lib.rs, crates/scap-screencapturekit/src/capture.rs, crates/scap-screencapturekit/src/config.rs, crates/scap-screencapturekit/src/targets.rs, crates/scap-screencapturekit/examples/cli.rs
Add macOS-only capture library: targets (Display/Window), StreamCfgBuilder, Capturer with callbacks, and example CLI.

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant Display (Win)
  participant Capturer (D3D)
  participant Callback
  participant FFmpeg

  App->>Display (Win): primary()
  App->>Capturer (D3D): new(item, settings).start(cb)
  Capturer (D3D)->>Capturer (D3D): init D3D11 + frame pool
  loop until stopped
    Capturer (D3D)->>Callback: on_frame(Frame)
    Callback->>FFmpeg: Frame.as_ffmpeg()
    FFmpeg-->>Callback: Video frame
  end
  App->>Capturer (D3D): stop()
Loading
sequenceDiagram
  participant App
  participant Targets (macOS)
  participant StreamCfgBuilder
  participant Capturer (SCKit)
  participant Callback
  participant FFmpeg

  App->>Targets (macOS): Display::primary()
  App->>StreamCfgBuilder: with_fps/size/cursor.build()
  App->>Capturer (SCKit): builder(target,cfg).with_callbacks().build()
  App->>Capturer (SCKit): start()
  loop until stop
    Capturer (SCKit)->>Callback: did_output(Frame::Screen)
    Callback->>FFmpeg: VideoFrame.as_ffmpeg()
    FFmpeg-->>Callback: Video frame
  end
  App->>Capturer (SCKit): stop()
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90 minutes

Poem

In windows of glass and apples that gleam,
I hop through frames like a caffeinated dream.
D3D hums, SCKit sings—what luck!
Futures aligned, our bytes don’t get stuck.
With FFmpeg whiskers, I twitch and I zip—
Capture, convert, and carrot—ship! 🥕🖥️🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dd884d and a0d5d0f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (28)
  • .github/workflows/ci.yml (1 hunks)
  • Cargo.toml (1 hunks)
  • apps/desktop/src-tauri/Cargo.toml (1 hunks)
  • crates/camera-directshow/Cargo.toml (2 hunks)
  • crates/camera-directshow/examples/cli.rs (0 hunks)
  • crates/camera-mediafoundation/Cargo.toml (0 hunks)
  • crates/camera/Cargo.toml (1 hunks)
  • crates/editor/Cargo.toml (1 hunks)
  • crates/export/Cargo.toml (1 hunks)
  • crates/media/Cargo.toml (1 hunks)
  • crates/recording/Cargo.toml (1 hunks)
  • crates/rendering-skia/Cargo.toml (1 hunks)
  • crates/rendering/Cargo.toml (1 hunks)
  • crates/scap-direct3d/Cargo.toml (1 hunks)
  • crates/scap-direct3d/examples/cli.rs (1 hunks)
  • crates/scap-direct3d/src/lib.rs (1 hunks)
  • crates/scap-ffmpeg/Cargo.toml (1 hunks)
  • crates/scap-ffmpeg/examples/cli.rs (1 hunks)
  • crates/scap-ffmpeg/src/direct3d.rs (1 hunks)
  • crates/scap-ffmpeg/src/lib.rs (1 hunks)
  • crates/scap-ffmpeg/src/screencapturekit.rs (1 hunks)
  • crates/scap-screencapturekit/Cargo.toml (1 hunks)
  • crates/scap-screencapturekit/README.md (1 hunks)
  • crates/scap-screencapturekit/examples/cli.rs (1 hunks)
  • crates/scap-screencapturekit/src/capture.rs (1 hunks)
  • crates/scap-screencapturekit/src/config.rs (1 hunks)
  • crates/scap-screencapturekit/src/lib.rs (1 hunks)
  • crates/scap-screencapturekit/src/targets.rs (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch scap-crates

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants