diff --git a/example.js b/example.js index e3c6fae..f707358 100644 --- a/example.js +++ b/example.js @@ -7,6 +7,7 @@ async function main() { const recorder = aperture(); console.log('Screens:', await aperture.screens()); console.log('Audio devices:', await aperture.audioDevices()); + console.log('Video codecs:', aperture.videoCodecs); console.log('Preparing to record for 5 seconds'); await recorder.startRecording(); diff --git a/index.d.ts b/index.d.ts index cb05b8a..e6f993a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -56,7 +56,7 @@ declare namespace aperture { /** Video codec to use. - The `hevc` codec requires macOS 10.13 or newer. A computer with Intel 6th generation processor or newer is strongly recommended, as otherwise it will use software encoding, which only produces 3 FPS fullscreen recording. + A computer with Intel 6th generation processor or newer is strongly recommended for the `hevc` codec, as otherwise it will use software encoding, which only produces 3 FPS fullscreen recording. The `proRes422` and `proRes4444` codecs are uncompressed data. They will create huge files. */ @@ -110,7 +110,7 @@ declare const aperture: (() => aperture.Recorder) & { The key is the `videoCodec` option name and the value is the codec name. - It only returns `hevc` if you're on macOS 10.13 or newer and your computer supports HEVC hardware encoding. + It only returns `hevc` if your computer supports HEVC hardware encoding. @example ``` diff --git a/index.js b/index.js index aadc722..7607da0 100644 --- a/index.js +++ b/index.js @@ -16,21 +16,27 @@ const getRandomId = () => Math.random().toString(36).slice(2, 15); const BIN = path.join(electronUtil.fixPathForAsarUnpack(__dirname), 'aperture'); const supportsHevcHardwareEncoding = (() => { - if (!macosVersion.isGreaterThanOrEqualTo('10.13')) { - return false; + const cpuModel = os.cpus()[0].model; + + // All Apple silicon Macs support HEVC hardware encoding. + if (cpuModel.startsWith('Apple ')) { // Source string example: `'Apple M1'` + return true; } // Get the Intel Core generation, the `4` in `Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz` // More info: https://www.intel.com/content/www/us/en/processors/processor-numbers.html - const result = /Intel.*Core.*i[57]-(\d)/.exec(os.cpus()[0].model); + // Example strings: + // - `Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz` + // - `Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz` + const result = /Intel.*Core.*i\d+-(\d)/.exec(cpuModel); // Intel Core generation 6 or higher supports HEVC hardware encoding - return result && Number(result[1]) >= 6; + return result && Number.parseInt(result[1], 10) >= 6; })(); class Aperture { constructor() { - macosVersion.assertGreaterThanOrEqualTo('10.12'); + macosVersion.assertGreaterThanOrEqualTo('10.13'); } startRecording({ diff --git a/readme.md b/readme.md index bf3b78c..066180b 100644 --- a/readme.md +++ b/readme.md @@ -66,7 +66,7 @@ Example: #### aperture.videoCodecs -> `Map` -Get a list of available video codecs. The key is the `videoCodec` option name and the value is the codec name. It only returns `hevc` if you're on macOS 10.13 or newer and your computer supports HEVC hardware encoding. +Get a list of available video codecs. The key is the `videoCodec` option name and the value is the codec name. It only returns `hevc` if your computer supports HEVC hardware encoding. Example: @@ -167,7 +167,7 @@ Type: `string`\ Default: `'h264'`\ Values: `'hevc' | 'h264' | 'proRes422' | 'proRes4444'` -The `hevc` codec requires macOS 10.13 or newer. A computer with Intel 6th generation processor or newer is strongly recommended, as otherwise it will use software encoding, which only produces 3 FPS fullscreen recording. +A computer with Intel 6th generation processor or newer is strongly recommended for the `hevc` codec, as otherwise it will use software encoding, which only produces 3 FPS fullscreen recording. The [`proRes422` and `proRes4444`](https://documentation.apple.com/en/finalcutpro/professionalformatsandworkflows/index.html#chapter=10%26section=2%26tasks=true) codecs are uncompressed data. They will create huge files.