capturekit
TypeScript icon, indicating that this package has built-in type declarations

1.0.13 • Public • Published

CaptureKit

Record the screen on macOS with ScreenCaptureKit.

Requirements

  • macOS 12.0 or later

Install

npm install capturekit

Requires macOS 12.0 or later.

Usage

import {setTimeout} from 'node:timers/promises';
import { recorder } from 'capturekit';

const options = {
	fps: 30,
	cropArea: {
		x: 100,
		y: 100,
		width: 500,
		height: 500,
	},
};

await recorder.startRecording(options);

await setTimeout(3000);

console.log(await recorder.stopRecording());
//=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/cdf4f7df426c97880f8c10a1600879f7.mov'

API

screens() -> Promise<Object[]>

Get a list of screens. The first screen is the primary screen.

Example:

[
	{
		id: 69732482,
		name: 'Color LCD',
	},
];

audioDevices() -> Promise<Object[]>

Get a list of audio devices.

Example:

[
	{
		id: 'AppleHDAEngineInput:1B,0,1,0:1',
		name: 'Built-in Microphone',
	},
];

recorder

recorder.startRecording(options?)

Returns a Promise that fullfills when the recording starts or rejects if the recording didn't start after 5 seconds.

recorder.stopRecording()

Returns a Promise for the path to the screen recording file.

Options

Type: object

fps

Type: number
Default: 30

Number of frames per seconds.

cropArea

Type: object
Default: undefined

Record only an area of the screen. Accepts an object with x, y, width, height properties.

showCursor

Type: boolean
Default: true

Show the cursor in the screen recording.

screenId

Type: number
Default: capture.screens()[0] (Primary screen)

Screen to record.

Why

providing a JavaScript interface to the best available method for recording the screen using ScreenCaptureKit.

Package Sidebar

Install

npm i capturekit

Weekly Downloads

15

Version

1.0.13

License

MIT

Unpacked Size

3.04 MB

Total Files

7

Last publish

Collaborators

  • covaxin