A high-performance, ultra-low-latency macOS screen and audio capture engine built on modern Apple frameworks. Engineered entirely in Swift 6 with strict concurrency compliance, MacWcap bypasses the overhead of legacy capture APIs to deliver crash-resilient, hardware-accelerated recordings up to 120+ FPS while maintaining an ultra-lightweight CPU, memory, and battery footprint.
- Fully Swift 6 Compliant: 100% thread-safe domain architecture utilizing strict concurrency checks,
Sendablevalidation, and lock-free execution blocks across multi-threaded queues. - Ultra-Low Latency & High Efficiency: Designed for maximum speed and minimal system load, consuming exceptionally low CPU, GPU, and memory resources for minimal battery drain during high-throughput capture.
- Crash-Resilient Recording: Utilizes Fragmented MP4 (fMP4) structure to ensure your captured video remains fully uncorrupted and recoverable, even during unexpected system or app crashes mid-recording.
- Low-Latency Locking Primitives: Uses modern
OSAllocatedUnfairLockprimitives instead of heavy actor hops or semaphores, ensuring zero UI thread blocking. - Zero-Allocation Tracking: Drops incomplete or delayed frames safely at the engine level via low-level
CMSampleBufferattachments before memory allocation occurs. - Hardware-Accelerated Pro Encoding: Strict 16-byte macroblock boundary alignment supporting 10-bit HDR color profiles (
ITU_R_2100_HLG) and smooth high-framerate capture (up to 240 FPS). - Flexible Audio Routing: Captures granular multi-app configurations, featuring precise internal presentation timestamp alignment to prevent audio/video drift.
MacWcap is engineered around maximum throughput with minimal CPU/GPU overhead. Below are the key structural details powering its performance:
Standard MP4 files store critical metadata (moov atom) at the end of the recording session. If the application terminates or the system crashes before completion, the file becomes unplayable. MacWcap utilizes Fragmented MP4s, continuously flushing media chunks and metadata to disk.
- The Optimization: Ensures complete file resiliency and zero data loss during unforeseen interrupts or crashes while keeping disk write overhead negligible.
High-framerate capturing (up to 240Hz) can easily swamp the system memory allocator if frames back up. To solve this, WcapEngine performs an inline, zero-allocation extraction of the SCStreamFrameInfo.status primitive directly out of CMSampleBufferGetSampleAttachmentsArray.
- The Optimization: If the status is not explicitly
.complete, the frame is instantly dropped before any downstream structures are initialized, maintaining a flat memory profile and keeping CPU usage minimal.
Instead of using cross-actor hopping (which incurs costly thread context switches on the @MainActor), StreamWriter captures and appends frame data on a dedicated userInteractive queue.
- The Optimization: Thread state, frame timing, and estimated file boundaries are protected by
OSAllocatedUnfairLock, providing ultra-low-latency execution with Swift 6 strict concurrency guarantees.
Video hardware encoders slice processing frames into macroblocks. MacWcap implements strict bitwise clipping (& ~15) to ensure custom regions and window coordinates are explicitly forced to 16-byte boundaries.
- The Optimization: Bypasses software-driven scaling pipelines. The GPU writes directly to the hardware encoder frame buffers without extra memory copies or letterboxing, significantly conserving battery life.
Virtual audio routers and standard hardware inputs often exhibit small timing discrepancies during initialization. The pipeline monitors CMTimeCompare baselines globally, completely ignoring any audio sample packets generated chronologically prior to the exact presentation timestamp of the very first complete video frame.
The core of MacWcap is built using standard Swift & configuration files:
MacWcapApp.swift: The main SwiftUI application lifecycle driver initializing the global app state.WcapEngine.swift: The performance-critical capture engine managing activeSCStreamlifecycles, directAVAssetWriterinputs, and zero-allocation frame dropping.RegionSelector.swift: The UI component responsible for precise window coordinates and custom bounding-box calculations for cropped screen capture.GlobalHotkeyManager.swift: Handles modern macOS accessibility APIs for real-time background hotkey mapping. (Currently prepared for implementation in a future update).Info.plist: Property list containing application configuration, system version constraints, menu bar app behaviors (LSUIElement), and privacy permission keys.
- Operating System: macOS 14.0 (Sonoma) or newer.
- SDK: Xcode 15.0+ / Swift 6 toolchain.
- Frameworks:
ScreenCaptureKit,AVFoundation,VideoToolbox,QuartzCore,AppKit,SwiftUI.
If you prefer not to build from source:
- Go to the Releases tab on the right side of this repository page.
- Download the
MacWcapInstaller.dmgdisk image. - Open the file and move the application bundle into your
/Applicationsdirectory. - Open the application.
⚠️ Note: Because this app communicates with native screen buffers and hooks into display context layouts, macOS will prompt you to grant Screen Recording permissions underSystem Settings -> Privacy & Security.
If you are working directly with the .swift source files and Info.plist, you can compile the application using Xcode or manually via the Terminal.
- Open Xcode and select File > New > Project...
- Choose macOS as the platform and select App.
- Set the project options:
- Product Name:
MacWcap - Interface:
SwiftUI - Language:
Swift
- Product Name:
- Add the source files (
MacWcapApp.swift,WcapEngine.swift,RegionSelector.swift,GlobalHotkeyManager.swift) into your project navigator. - In Target Settings:
- Under General > Deployment Info, set the minimum macOS target to 14.0.
- Under Build Settings > Swift Compiler - Incoming Language Features, set Swift Language Version to Swift 6.
- Under Info, replace or point the project settings to your provided
Info.plist.
- Go to Signing & Capabilities:
- Ensure Hardened Runtime is enabled if required.
- Add the Screen Capture entitlement if prompted by your setup.
- Press
Cmd + Rto build and run the app.
You can assemble the macOS .app bundle manually using swiftc and standard CLI tools:
# 1. Create the App Bundle Directory Structure
mkdir -p MacWcap.app/Contents/MacOS
mkdir -p MacWcap.app/Contents/Resources
# 2. Compile the Swift Source Files using Swift 6 Toolchain
swiftc -O \
-framework Foundation \
-framework AppKit \
-framework SwiftUI \
-framework ScreenCaptureKit \
-framework AVFoundation \
-framework Carbon \
WcapEngine.swift \
GlobalHotkeyManager.swift \
RegionSelector.swift \
MacWcapApp.swift \
-o MacWcap
# 3. Copy the Info.plist into the Bundle
cp Info.plist MacWcap.app/Contents/Info.plist
# 4. Move MacWcap binary into the Bundle
mv MacWcap MacWcap.app/Contents/MacOS/MacWcap
# 4. Code Sign the Application Bundle Locally
codesign --force --deep --sign - MacWcap.appOnce built, you can launch your app via CLI:
open MacWcap.appMacWcap operates entirely as a lightweight utility residing directly in your macOS menu bar, staying completely out of your workspace until triggered.
- Status Dropdown: Click the
MacWcapstatus icon in your system menu bar to reveal all targeting options and runtime settings. - Target Options: Select whether to capture your entire primary display or trigger the Region Selector overlay to click and drag a custom bounding box around a specific area of your desktop.
- Toggling Capture: Click the Start and Stop indicators directly inside the dropdown menu to initiate or finalize a recording session.
- 🔮 Upcoming Feature: Global hotkey mapping via
GlobalHotkeyManager.swiftis actively being developed to support starting and stopping recordings seamlessly via background keyboard shortcuts.
You can fine-tune the recording engine directly from the preferences toggle inside the dropdown menu:
- Framerate Target (FPS): Adjust your capture speed up to 120Hz (or 240Hz on supported ProMotion displays) for fluid motion tracking.
- Color Depth (10-Bit HDR vs. 8-Bit): Toggle 10-bit color spaces on to output rich
ITU_R_2100_HLGhigh-dynamic-range video, or use 8-bit for smaller overall file sizes. - Audio Capture Modes:
- All System & App Audio: Records all ongoing output sounds across your Mac.
- Only Frontmost App Audio: Granularly isolates and tracks only the app active in the foreground, automatically filtering out hidden system alarms or background notifications.
- Container Formats: Choose between Fragmented MP4 (default & highly recommended for crash resilience), Standard MP4, or native QuickTime (.mov) profiles.
- Output Automation: Toggle whether the system should automatically launch the video file or instantly reveal its file path in Finder the moment recording finishes.
This project is a modern macOS implementation inspired by wcap by Mārtiņš Možeiko (@mmozeiko).
While the original wcap is a legendary, low-overhead screen recorder built for Windows utilizing clean Win32/DirectX APIs, MacWcap brings that same technical philosophy—minimal overhead, high frame rates, low CPU/battery consumption, and strict architectural optimization—to macOS using ScreenCaptureKit, modern Swift 6 strict concurrency, and OSAllocatedUnfairLock mechanics.
This project is licensed under the GNU General Public License v3.0 (GPLv3).
- Permissions: Commercial use, modification, distribution, and patent use.
- Conditions: Any modifications or larger works incorporating this source code must also be made open-source under the same GPLv3 terms, providing complete source disclosure.
See the LICENSE file for the full legal text.
- Icon provided by Icons8