1.0.22 • Published 3 months ago

screencapturekit v1.0.22

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

ScreenCaptureKit Node.js

A Node.js wrapper for Apple's ScreenCaptureKit module. This package allows screen recording on macOS with optimal performance using Apple's native APIs.

Features

  • High-performance screen recording
  • HDR (High Dynamic Range) support for macOS 13+ (Ventura)
  • System audio capture
  • Microphone audio capture (macOS 15+)
  • Direct-to-file recording (simplified API for macOS 15+)
  • Post-processing capabilities for audio tracks with FFmpeg
  • Cropping support (capture specific screen areas)
  • Multiple options control (FPS, cursor display, click highlighting)
  • Support for various video codecs (H264, HEVC, ProRes)
  • Listing available screens and audio devices

Requirements

  • macOS 10.13 (High Sierra) or newer
  • Node.js 14 or newer
  • FFmpeg (for post-processing audio tracks)

FFmpeg Installation

FFmpeg is required for post-processing audio tracks. Here's how to install it on different systems:

macOS

Using Homebrew:

brew install ffmpeg

Linux (Debian/Ubuntu)

Using apt package manager:

sudo apt update && sudo apt install ffmpeg

Windows

You have several options:

  1. Using Chocolatey (recommended if you have Chocolatey installed):
choco install ffmpeg
  1. Using the MSI Installer (easiest method):

    • Download the FFmpeg Installer from GitHub
    • Run the MSI file and follow the installation wizard
    • FFmpeg will be automatically added to your system PATH
  2. Manual Installation:

    • Download FFmpeg from ffmpeg.org
    • Extract the archive
    • Add FFmpeg to your system PATH manually

To verify the installation on any system, open a terminal/command prompt and run:

ffmpeg -version

Installation

npm install screencapturekit

Usage

Simple Screen Recording

import createScreenRecorder from 'screencapturekit';

const recorder = createScreenRecorder();

// Start recording
await recorder.startRecording();

// Wait for desired duration...
setTimeout(async () => {
  // Stop recording
  const videoPath = await recorder.stopRecording();
  console.log('Video recorded at:', videoPath);
}, 5000);

Recording with Advanced Options

import createScreenRecorder from 'screencapturekit';

const recorder = createScreenRecorder();

// Start recording with options
await recorder.startRecording({
  fps: 60,
  showCursor: true,
  highlightClicks: true,
  screenId: 0,
  videoCodec: 'h264',
  enableHDR: true, // Enable HDR recording (macOS 13+)
  microphoneDeviceId: 'device-id', // Enable microphone capture (macOS 15+)
  recordToFile: true, // Use direct recording API (macOS 15+)
  cropArea: {
    x: 0,
    y: 0,
    width: 1920,
    height: 1080
  }
});

// Wait...

// Stop recording
const videoPath = await recorder.stopRecording();

List Available Screens

import { screens } from 'screencapturekit';

const availableScreens = await screens();
console.log(availableScreens);

List Audio Devices

import { audioDevices, microphoneDevices } from 'screencapturekit';

// System audio devices
const systemAudio = await audioDevices();
console.log(systemAudio);

// Microphone devices
const mics = await microphoneDevices();
console.log(mics);

Check Support for Features

import { supportsHDRCapture, supportsDirectRecordingAPI, supportsMicrophoneCapture } from 'screencapturekit';

if (supportsHDRCapture) {
  console.log('Your system supports HDR capture');
}

if (supportsDirectRecordingAPI) {
  console.log('Your system supports direct-to-file recording');
}

if (supportsMicrophoneCapture) {
  console.log('Your system supports microphone capture');
}

Recording Options

OptionTypeDefaultDescription
fpsnumber30Frames per second
cropAreaobjectundefinedCropping area {x, y, width, height}
showCursorbooleantrueDisplay cursor in recording
highlightClicksbooleanfalseHighlight mouse clicks
screenIdnumber0ID of screen to capture
audioDeviceIdnumberundefinedSystem audio device ID
microphoneDeviceIdstringundefinedMicrophone device ID (macOS 15+)
videoCodecstring'h264'Video codec ('h264', 'hevc', 'proRes422', 'proRes4444')
enableHDRbooleanfalseEnable HDR recording (macOS 13+)
recordToFilebooleanfalseUse direct recording API (macOS 15+)
audioOnlybooleanfalseRecord audio only, will convert to mp3 after recording

Post-processing

When both system audio and microphone are recorded, the library uses FFmpeg to merge these tracks into a single video file. This happens automatically in the stopRecording() method. Make sure you have FFmpeg installed on your system.

Development

npm install
npm run build

Tests

npm test

License

MIT

1.0.22

3 months ago

1.0.20

3 months ago

1.0.19

3 months ago

1.0.18

3 months ago

1.0.17

3 months ago

1.0.16

3 months ago

1.0.15

3 months ago

1.0.14

3 months ago

1.0.13

3 months ago

1.0.12

3 months ago

1.0.11

3 months ago

1.0.9

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

0.1.1

3 months ago