From cef40cd2d9e6ca623f7b19ff74dfb97d1bb6c59d Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 10:15:29 -0700 Subject: [PATCH 01/10] appends `destination` option string for `.startRecording()` --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7b65f6e..7be0517 100644 --- a/index.js +++ b/index.js @@ -32,6 +32,7 @@ class Aperture { } startRecording({ + destination = undefined, fps = 30, cropArea = undefined, showCursor = true, @@ -46,7 +47,12 @@ class Aperture { return; } - this.tmpPath = tempy.file({extension: 'mp4'}); + this.tmpPath = destination ? tempy.file({extension: 'mp4'}); + + if (destination && (typeof destination !== 'string' || !destination.includes('mp4')) { + reject(new Error('Invalid `destination` option string')); + return; + } if (highlightClicks === true) { showCursor = true; From edd8878e0008d638cc19fbbc66fee6f4368208e1 Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 10:17:44 -0700 Subject: [PATCH 02/10] Update readme.md --- readme.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 3e567e7..70b735e 100644 --- a/readme.md +++ b/readme.md @@ -20,6 +20,7 @@ const aperture = require('aperture')(); const options = { fps: 30, + destination: '/private/var/folders/3x/myVideo.mp4', cropArea: { x: 100, y: 100, @@ -32,7 +33,7 @@ const options = { await aperture.startRecording(options); await delay(3000); console.log(await aperture.stopRecording()); - //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/cdf4f7df426c97880f8c10a1600879f7.mp4' + //=> '/private/var/folders/3x/myVideo.mp4' })(); ``` @@ -96,6 +97,13 @@ Returns a `Promise` for the path to the screen recording file. ## Options +#### destination + +Type: `string`
+Default: `undefined` + +Destination of the output file. When `undefined`, destination will be generated. + #### fps Type: `number`
From 55730ae70e050e469ce10baf2b672e0d8977a808 Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 10:18:55 -0700 Subject: [PATCH 03/10] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7be0517..e92506d 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,7 @@ class Aperture { return; } - this.tmpPath = destination ? tempy.file({extension: 'mp4'}); + this.tmpPath = destination ? destination : tempy.file({extension: 'mp4'}); if (destination && (typeof destination !== 'string' || !destination.includes('mp4')) { reject(new Error('Invalid `destination` option string')); From 95c7dc3c1a290b3531e347207c5b6529c8223cda Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 10:19:34 -0700 Subject: [PATCH 04/10] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index e92506d..eeb2342 100644 --- a/index.js +++ b/index.js @@ -49,7 +49,7 @@ class Aperture { this.tmpPath = destination ? destination : tempy.file({extension: 'mp4'}); - if (destination && (typeof destination !== 'string' || !destination.includes('mp4')) { + if (destination && (typeof destination !== 'string' || !destination.includes('mp4'))) { reject(new Error('Invalid `destination` option string')); return; } From 5adcfe63b18c8343953a64103f000b3eb5e1aec8 Mon Sep 17 00:00:00 2001 From: alectrocute <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 10:26:35 -0700 Subject: [PATCH 05/10] add to example --- example.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/example.js b/example.js index 2b6e5f3..6f8c979 100644 --- a/example.js +++ b/example.js @@ -1,5 +1,5 @@ 'use strict'; -const fs = require('fs'); +const path = require('path'); const delay = require('delay'); const aperture = require('.'); @@ -8,12 +8,13 @@ async function main() { console.log('Screens:', await aperture.screens()); console.log('Audio devices:', await aperture.audioDevices()); console.log('Preparing to record for 5 seconds'); - await recorder.startRecording(); + await recorder.startRecording({ + destination: path.join(__dirname, 'test.mp4') + }); console.log('Recording started'); await delay(5000); const fp = await recorder.stopRecording(); - fs.renameSync(fp, 'recording.mp4'); - console.log('Video saved in the current directory'); + console.log('Video saved in the current directory', fp); } main().catch(console.error); From 92925a7c6c4a4048ad4c6448a7a85dc36bf0c7b1 Mon Sep 17 00:00:00 2001 From: alectrocute <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 10:29:20 -0700 Subject: [PATCH 06/10] changes to --- example.js | 2 +- readme.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example.js b/example.js index 6f8c979..9d1af82 100644 --- a/example.js +++ b/example.js @@ -9,7 +9,7 @@ async function main() { console.log('Audio devices:', await aperture.audioDevices()); console.log('Preparing to record for 5 seconds'); await recorder.startRecording({ - destination: path.join(__dirname, 'test.mp4') + destinationPath: path.join(__dirname, 'test.mp4') }); console.log('Recording started'); await delay(5000); diff --git a/readme.md b/readme.md index 70b735e..eed4314 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ const aperture = require('aperture')(); const options = { fps: 30, - destination: '/private/var/folders/3x/myVideo.mp4', + destinationPath: '/private/var/folders/3x/myVideo.mp4', cropArea: { x: 100, y: 100, @@ -97,7 +97,7 @@ Returns a `Promise` for the path to the screen recording file. ## Options -#### destination +#### destinationPath Type: `string`
Default: `undefined` From c7341da73ce2def942f486a9aaaf7d3a1f1a6d6b Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 14:55:16 -0700 Subject: [PATCH 07/10] Update readme.md --- readme.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index eed4314..2ec55dd 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,4 @@ + # aperture-node [![Build Status](https://travis-ci.org/wulkano/aperture-node.svg?branch=master)](https://travis-ci.org/wulkano/aperture-node) > Record the screen on macOS from Node.js @@ -89,7 +90,7 @@ Map { 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. +Fulfills when the recording starts or rejects if the recording didn't start after 5 seconds. #### recorder.stopRecording() @@ -102,7 +103,11 @@ Returns a `Promise` for the path to the screen recording file. Type: `string`
Default: `undefined` -Destination of the output file. When `undefined`, destination will be generated. +Destination of the output file. When `undefined`, destination will be generated using [tempy](https://github.com/sindresorhus/tempy) (default). + +`destinationPath` should only be used when necessary. [tempy](https://github.com/sindresorhus/tempy) is used to generate an available filename and path in the user's temporary directory, eg. `/private/var/folders/3x/jf5977fn79j/T/vid.mp4`. + +`destinationPath` can be useful when needing to store temporary data on a different external network or local drive, allowing for higher capacity file storage ([further discussion](https://github.com/wulkano/aperture-node/pull/7#issuecomment-533199701)). #### fps From 5773ad126358275cf4fd288b051463a7bdb2a737 Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 14:55:55 -0700 Subject: [PATCH 08/10] Update readme.md --- readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 2ec55dd..c7a72c6 100644 --- a/readme.md +++ b/readme.md @@ -21,7 +21,6 @@ const aperture = require('aperture')(); const options = { fps: 30, - destinationPath: '/private/var/folders/3x/myVideo.mp4', cropArea: { x: 100, y: 100, @@ -34,7 +33,7 @@ const options = { await aperture.startRecording(options); await delay(3000); console.log(await aperture.stopRecording()); - //=> '/private/var/folders/3x/myVideo.mp4' + //=> '/private/var/folders/3x/jf5977fn79j/T/cdf4f7df426c97880f8c10a1600879f7.mp4' })(); ``` From d699b1ed7eae196533cf114b4773d7ed126c246e Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 14:58:57 -0700 Subject: [PATCH 09/10] Update readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index c7a72c6..de82965 100644 --- a/readme.md +++ b/readme.md @@ -104,10 +104,10 @@ Default: `undefined` Destination of the output file. When `undefined`, destination will be generated using [tempy](https://github.com/sindresorhus/tempy) (default). -`destinationPath` should only be used when necessary. [tempy](https://github.com/sindresorhus/tempy) is used to generate an available filename and path in the user's temporary directory, eg. `/private/var/folders/3x/jf5977fn79j/T/vid.mp4`. - `destinationPath` can be useful when needing to store temporary data on a different external network or local drive, allowing for higher capacity file storage ([further discussion](https://github.com/wulkano/aperture-node/pull/7#issuecomment-533199701)). +`destinationPath` should only be used when necessary. If `destinationPath` is not defined, then [tempy](https://github.com/sindresorhus/tempy) is used to generate an available filename and path in the user's temporary directory, eg. `/private/var/folders/3x/jf5977fn79j/T/vid.mp4`. + #### fps Type: `number`
From 7b868a1f5bc024a8204a29e891e46e1153a26a30 Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Mon, 1 Jun 2020 14:59:48 -0700 Subject: [PATCH 10/10] Update readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index de82965..0a074a2 100644 --- a/readme.md +++ b/readme.md @@ -104,9 +104,9 @@ Default: `undefined` Destination of the output file. When `undefined`, destination will be generated using [tempy](https://github.com/sindresorhus/tempy) (default). -`destinationPath` can be useful when needing to store temporary data on a different external network or local drive, allowing for higher capacity file storage ([further discussion](https://github.com/wulkano/aperture-node/pull/7#issuecomment-533199701)). +`destinationPath` can be useful when needing to store temporary data on a different external network or local drive, allowing for higher capacity file storage ([further discussion](https://github.com/wulkano/aperture-node/pull/7#issuecomment-533199701)). -`destinationPath` should only be used when necessary. If `destinationPath` is not defined, then [tempy](https://github.com/sindresorhus/tempy) is used to generate an available filename and path in the user's temporary directory, eg. `/private/var/folders/3x/jf5977fn79j/T/vid.mp4`. +This option should only be used when necessary. If `destinationPath` is not defined, then [tempy](https://github.com/sindresorhus/tempy) is used to generate an available filename and path in the user's temporary directory, eg. `/private/var/folders/3x/jf5977fn79j/T/vid.mp4`. #### fps