diff --git a/README.md b/README.md index 70cc9b9..8b90f9a 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,13 @@ Edit specs are JavaScript / JSON objects describing the whole edit operation wit layer: { fontPath, // ...more layer defaults + }, + layerType: { + 'fill-color': { + color: '#ff6666', } + // ...more per-layer-type defaults + }, }, audioFilePath, keepSourceAudio, diff --git a/examples/subtitle.json5 b/examples/subtitle.json5 index 3bd711b..0e31209 100644 --- a/examples/subtitle.json5 +++ b/examples/subtitle.json5 @@ -2,6 +2,7 @@ outPath: './subtitle.mp4', defaults: { layer: { fontPath: './assets/Patua_One/PatuaOne-Regular.ttf' }, + layerType: { 'fill-color': { color: '#00aa00' } } }, clips: [ { duration: 2, layers: [ diff --git a/index.js b/index.js index 22e8663..8e8f72a 100644 --- a/index.js +++ b/index.js @@ -141,7 +141,9 @@ module.exports = async (config = {}) => { const transition = calcTransition(defaults, userTransition, clipIndex === clipsIn.length - 1); let layersOut = flatMap(await pMap(layers, async (layerIn) => { - const layer = { ...defaults.layer, ...layerIn }; + const globalLayerDefaults = defaults.layer || {}; + const thisLayerDefaults = (defaults.layerType || {})[layerIn.type]; + const layer = { ...globalLayerDefaults, ...thisLayerDefaults, ...layerIn }; const { type, path } = layer; if (type === 'video') {