Skip to content

Phase 2: Core Recording EngineΒ #3

@coderabbitai

Description

@coderabbitai

🎯 Objective

Implement the core screen recording functionality using Windows Desktop Duplication API with cursor tracking, audio capture, and video encoding.

πŸ“‹ Tasks

2.1 Windows Desktop Duplication API Integration ⚑ HIGH PRIORITY

  • Research available libraries:
    • Evaluate windows-capture npm package
    • Assess if custom native C++ addon is needed
    • Document pros/cons of each approach
  • Choose implementation strategy
  • If using native addon:
    • Set up node-addon-api project structure
    • Create C++ bindings to DXGI Desktop Duplication API
    • Implement IDXGIOutputDuplication interface wrapper
    • Implement frame acquisition from GPU
    • Test on different GPU vendors (NVIDIA, AMD, Intel)
  • If using library:
    • Install and configure chosen library
    • Create wrapper module for consistent API
  • Implement features:
    • Capture frames from specific monitor
    • Support multi-monitor selection
    • Target 60 FPS minimum capture rate
    • Implement frame buffer retrieval
    • Add frame timing/synchronization
  • Set up IPC for streaming frames to renderer process
  • Optimize memory usage (reuse buffers)
  • Add error handling for GPU unavailable scenarios

2.2 Cursor Position Tracking

File: electron/recorder/cursorTracking.js

  • Create cursor tracking module
  • Integrate Windows GetCursorPos API
    • Capture cursor position at 120Hz+ frequency
    • Store X/Y coordinates with precise timestamps
  • Track cursor state changes:
    • Detect cursor icon type (arrow, hand, text, etc.)
    • Record cursor visibility state
  • Implement click detection:
    • Capture left mouse button events
    • Capture right mouse button events
    • Store click events with timestamps
    • Add optional keyboard event tracking
  • Create synchronized data structure:
    • Align cursor data with frame timestamps
    • Implement efficient storage format (JSON/binary)
    • Add data serialization for saving

2.3 Audio Capture

  • Implement system audio capture:
    • Research Windows WASAPI vs Web Audio API
    • Choose implementation approach
    • Capture desktop audio output
    • Handle audio device selection
  • Implement microphone capture:
    • Add microphone input support
    • Allow user to toggle mic on/off
    • Mix system audio and mic audio
  • Audio processing:
    • Synchronize audio with video frames
    • Handle sample rate conversion if needed
    • Add audio level monitoring
    • Implement audio buffer management

2.4 Video Encoding Pipeline

File: electron/recorder/videoEncoder.js

  • Integrate FFmpeg:
    • Download and bundle FFmpeg binaries
    • Create FFmpeg process wrapper
    • Set up frame streaming to FFmpeg stdin
  • Implement encoding options:
    • Configure H.264 codec settings
    • Support quality presets (720p, 1080p, 1440p, 4K)
    • Configure bitrate settings
    • Set up frame rate control
  • Create encoding modes:
    • Real-time encoding mode (encode while recording)
    • Raw capture mode (save frames, encode later)
    • Allow user to choose mode
  • Audio encoding:
    • Mux audio streams with video
    • Configure AAC audio codec
    • Sync audio/video streams
  • Add progress monitoring:
    • Parse FFmpeg output for progress
    • Calculate encoding speed
    • Estimate time remaining

2.5 Recording Session Management

  • Create recording controller:
    • Start recording command
    • Stop recording command
    • Pause/resume functionality
    • Cancel recording with cleanup
  • Implement session state:
    • Track recording status
    • Store session metadata
    • Calculate recording duration
  • File management:
    • Generate unique filenames
    • Save to user-specified directory
    • Handle disk space checks
    • Implement auto-save on crash

🎯 Success Criteria

  • Can capture screen at 60 FPS or higher
  • Cursor position is accurately tracked
  • Audio is captured and synchronized
  • Video is encoded to MP4 successfully
  • Can record, pause, and stop without crashes

πŸ”§ Technical Notes

  • Desktop Duplication API requires Windows 8 or later
  • GPU must support DirectX 11.1
  • Consider fallback for older systems (GDI+ capture)

πŸ”— Related

Estimated Duration: Weeks 2-3

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions