Browse Source

add flag keepSourceAudio

stateless
Mikael Finstad 6 years ago
parent
commit
6c3619494d
  1. 2
      README.md
  2. 5
      cli.js
  3. 3
      index.js

2
README.md

@ -113,6 +113,7 @@ Edit specs are JavaScript / JSON objects describing the whole edit operation wit
} }
}, },
audioFilePath, audioFilePath,
keepSourceAudio,
clips: [ clips: [
{ {
transition, 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** | | | `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` | | | `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 | | | | `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` | | | `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.fontPath` | `--font-path` | Set default font to a .ttf | System font | |
| `defaults.layer.*` | | Set any layer parameter that all layers will inherit | | | | `defaults.layer.*` | | Set any layer parameter that all layers will inherit | | |

5
cli.js

@ -32,6 +32,7 @@ const cli = meow(`
--fps FPS which all videos will be converted to --fps FPS which all videos will be converted to
--font-path Set default font to a .ttf --font-path Set default font to a .ttf
--audio-file-path Add an audio track --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) --fast, -f Fast mode (low resolution and FPS, useful for getting a quick preview)
--verbose, -v --verbose, -v
@ -45,6 +46,7 @@ const cli = meow(`
`, { `, {
flags: { flags: {
verbose: { type: 'boolean', alias: 'v' }, verbose: { type: 'boolean', alias: 'v' },
keepSourceAudio: { type: 'boolean' },
fast: { type: 'boolean', alias: 'f' }, fast: { type: 'boolean', alias: 'f' },
transitionDuration: { type: 'number' }, transitionDuration: { type: 'number' },
clipDuration: { type: 'number' }, clipDuration: { type: 'number' },
@ -92,7 +94,7 @@ const cli = meow(`
params.clips = clips.map((clip) => ({ layers: [clip] })); 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) { if (transitionName || transitionDuration != null) {
params.defaults.transition = {}; params.defaults.transition = {};
@ -110,6 +112,7 @@ const cli = meow(`
if (outPath) params.outPath = outPath; if (outPath) params.outPath = outPath;
if (audioFilePath) params.audioFilePath = audioFilePath; if (audioFilePath) params.audioFilePath = audioFilePath;
if (keepSourceAudio) params.keepSourceAudio = true;
if (width) params.width = width; if (width) params.width = width;
if (height) params.height = height; if (height) params.height = height;
if (fps) params.fps = fps; if (fps) params.fps = fps;

3
index.js

@ -36,6 +36,7 @@ module.exports = async (config = {}) => {
fps: requestedFps, fps: requestedFps,
defaults: defaultsIn = {}, defaults: defaultsIn = {},
audioFilePath: audioFilePathIn, audioFilePath: audioFilePathIn,
keepSourceAudio,
ffmpegPath = 'ffmpeg', ffmpegPath = 'ffmpeg',
ffprobePath = 'ffprobe', ffprobePath = 'ffprobe',
@ -250,7 +251,7 @@ module.exports = async (config = {}) => {
await fs.remove(tmpDir); await fs.remove(tmpDir);
await fs.mkdirp(tmpDir); await fs.mkdirp(tmpDir);
if (!audioFilePath) {
if (!audioFilePath && keepSourceAudio) {
audioFilePath = await editAudio({ clips, tmpDir }); audioFilePath = await editAudio({ clips, tmpDir });
} }

Loading…
Cancel
Save