Browse Source

add layerType defaults

stateless
Mikael Finstad 6 years ago
parent
commit
6501497ca3
  1. 6
      README.md
  2. 1
      examples/subtitle.json5
  3. 4
      index.js

6
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,

1
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: [

4
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') {

Loading…
Cancel
Save