$ npm install aperture
Requires macOS 10.10 or later.
const delay = require('delay');
const aperture = require('aperture')();
const options = {
fps: 30,
cropArea: {
x: 100,
y: 100,
width: 500,
height: 500
}
};
(async () => {
await aperture.startRecording(options);
await delay(3000);
console.log(await aperture.stopRecording());
//=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/cdf4f7df426c97880f8c10a1600879f7.mp4'
})();
See example.js
if you want to quickly try it out. (The example requires Node.js 7+)
Get a list of audio sources.
Example:
[{
id: 'AppleHDAEngineInput:1B,0,1,0:1',
name: 'Built-in Microphone'
}]
Returns a Promise
for the path to the screen recording file.
Fullfills when the recording starts or rejects if the recording didn't start after 5 seconds.
Returns a Promise
for the path to the screen recording file.
Type: number
Default: 30
Number of frames per seconds.
Type: Object
string
Default: 'none'
Record only an area of the screen. Accepts an object with x
, y
, width
, height
properties.
Type: boolean
Default: true
Show the cursor in the screen recording.
Type: boolean
Default: false
Highlight cursor clicks in the screen recording.
Enabling this will also enable the showCursor
option.
Type: string
Default: main
Display to record.
Type: Object
string
Default: 'none'
Audio source to include in the screen recording. Should be one of the id
's from aperture.getAudioSources()
.
Aperture was built to fulfill the needs of Kap, providing a JavaScript interface to the best available method for recording the screen. That's why it's currently a wrapper for a Swift script that records the screen using the AVFoundation framework.
Yes, we can, but the performance is terrible:
We want to bring Aperture to Linux and Windows, but we don't have time or resources for such tasks (we're Mac users), so any help is more than welcome. We just want to enforce two things: performance and quality – it doesn't matter how (ffmpeg
, custom built native lib, etc) they are achieved.
Aperture is in its early days. We're working on adding more features, such as export to GIF, compression options, support for multiple displays, support for audio, and much more. Check out our Aperture issues on Kap to learn more.