From 6c3619494da7707788f163a8ac3534371a6c2fc1 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sun, 6 Sep 2020 12:24:38 +0200 Subject: [PATCH] add flag keepSourceAudio --- README.md | 2 ++ cli.js | 5 ++++- index.js | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 530f7fd..1659455 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Edit specs are JavaScript / JSON objects describing the whole edit operation wit } }, audioFilePath, + keepSourceAudio, clips: [ { transition, @@ -144,6 +145,7 @@ Edit specs are JavaScript / JSON objects describing the whole edit operation wit | `height` | `--height` | Height which all media will be converted to | auto based on `width` and aspect ratio of **first video** | | | `fps` | `--fps` | FPS which all videos will be converted to | First video FPS or `25` | | | `audioFilePath` | `--audio-file-path` | Set an audio track for the whole video | | | +| `keepSourceAudio` | `--keep-source-audio` | Keep audio from source files | | | | `fast` | `--fast`, `-f` | Fast mode (low resolution and FPS, useful for getting a quick preview) | `false` | | | `defaults.layer.fontPath` | `--font-path` | Set default font to a .ttf | System font | | | `defaults.layer.*` | | Set any layer parameter that all layers will inherit | | | diff --git a/cli.js b/cli.js index 0a9134d..83ebd1b 100644 --- a/cli.js +++ b/cli.js @@ -32,6 +32,7 @@ const cli = meow(` --fps FPS which all videos will be converted to --font-path Set default font to a .ttf --audio-file-path Add an audio track + --keep-source-audio Keep audio from source files --fast, -f Fast mode (low resolution and FPS, useful for getting a quick preview) --verbose, -v @@ -45,6 +46,7 @@ const cli = meow(` `, { flags: { verbose: { type: 'boolean', alias: 'v' }, + keepSourceAudio: { type: 'boolean' }, fast: { type: 'boolean', alias: 'f' }, transitionDuration: { type: 'number' }, clipDuration: { type: 'number' }, @@ -92,7 +94,7 @@ const cli = meow(` params.clips = clips.map((clip) => ({ layers: [clip] })); } - const { verbose, transitionName, transitionDuration, clipDuration, width, height, fps, audioFilePath, fontPath, fast, out: outPath } = cli.flags; + const { verbose, transitionName, transitionDuration, clipDuration, width, height, fps, audioFilePath, fontPath, fast, out: outPath, keepSourceAudio } = cli.flags; if (transitionName || transitionDuration != null) { params.defaults.transition = {}; @@ -110,6 +112,7 @@ const cli = meow(` if (outPath) params.outPath = outPath; if (audioFilePath) params.audioFilePath = audioFilePath; + if (keepSourceAudio) params.keepSourceAudio = true; if (width) params.width = width; if (height) params.height = height; if (fps) params.fps = fps; diff --git a/index.js b/index.js index 3b6110f..22e8663 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,7 @@ module.exports = async (config = {}) => { fps: requestedFps, defaults: defaultsIn = {}, audioFilePath: audioFilePathIn, + keepSourceAudio, ffmpegPath = 'ffmpeg', ffprobePath = 'ffprobe', @@ -250,7 +251,7 @@ module.exports = async (config = {}) => { await fs.remove(tmpDir); await fs.mkdirp(tmpDir); - if (!audioFilePath) { + if (!audioFilePath && keepSourceAudio) { audioFilePath = await editAudio({ clips, tmpDir }); }