@andrewstart/av-encoder
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -39,2 +39,5 @@ "use strict"; | ||
const defaults = config.audio.default || { opusTargetBitrate: '32k', mp3Quality: '9', mono: false }; | ||
if (!defaults.formats) { | ||
defaults.formats = ['opus', 'caf', 'mp3']; | ||
} | ||
const cache = new utils_1.Cache(config.audio.cache || CACHE_FILE); | ||
@@ -54,9 +57,11 @@ await cache.load(); | ||
const currentSettings = Object.assign({}, defaults, group, override); | ||
const formats = currentSettings.formats; | ||
delete currentSettings.src; | ||
delete currentSettings.dest; | ||
delete currentSettings.overrides; | ||
delete currentSettings.formats; | ||
const oldSettings = cache.getSettings(file) || currentSettings; | ||
const changed = { opus: false, mp3: false, caf: false }; | ||
const changed = { opus: false, mp3: false, caf: false, webm: false }; | ||
if (currentSettings.mono != oldSettings.mono) { | ||
changed.opus = changed.caf = changed.mp3 = true; | ||
changed.opus = changed.caf = changed.mp3 = changed.webm = true; | ||
} | ||
@@ -66,2 +71,3 @@ if (currentSettings.opusTargetBitrate != oldSettings.opusTargetBitrate) { | ||
changed.caf = true; | ||
changed.webm = true; | ||
} | ||
@@ -72,3 +78,3 @@ if (currentSettings.mp3Quality != oldSettings.mp3Quality) { | ||
if (await cache.isDifferent(file, cwd, currentSettings)) { | ||
changed.opus = changed.caf = changed.mp3 = true; | ||
changed.opus = changed.caf = changed.mp3 = changed.webm = true; | ||
} | ||
@@ -79,2 +85,3 @@ else { | ||
const targetCaf = targetBase + '.caf'; | ||
const targetWebm = targetBase + '.webm'; | ||
const targetMp3 = targetBase + '.mp3'; | ||
@@ -87,2 +94,5 @@ if (!await fs.pathExists(targetOpus)) { | ||
} | ||
if (!await fs.pathExists(targetWebm)) { | ||
changed.webm = true; | ||
} | ||
if (!await fs.pathExists(targetMp3)) { | ||
@@ -92,3 +102,3 @@ changed.mp3 = true; | ||
} | ||
return Object.keys(changed).filter(k => changed[k]); | ||
return Object.keys(changed).filter(k => changed[k] && formats.includes(k)); | ||
}); | ||
@@ -106,2 +116,3 @@ for (const file of changed) { | ||
const targetCaf = targetBase + '.caf'; | ||
const targetWebm = targetBase + '.webm'; | ||
const targetMp3 = targetBase + '.mp3'; | ||
@@ -118,2 +129,6 @@ let writes = []; | ||
} | ||
if (file.modes.includes('webm')) { | ||
writes.push(`-c:a libopus -b:a ${settings.opusTargetBitrate} "${targetWebm}"`); | ||
encodes.push('webm'); | ||
} | ||
if (file.modes.includes('mp3')) { | ||
@@ -120,0 +135,0 @@ writes.push(`-c:a libmp3lame -q:a ${settings.mp3Quality} "${targetMp3}"`); |
{ | ||
"name": "@andrewstart/av-encoder", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Encodes and compresses audio/video for widely supported web formats", | ||
@@ -5,0 +5,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21173
390