Skip to content

Commit

Permalink
Merge pull request #207 from gabrieltorreiro/master
Browse files Browse the repository at this point in the history
add background control volume
  • Loading branch information
mifi authored Oct 10, 2022
2 parents d3d3a71 + 306234b commit dea54b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,13 @@ declare namespace Editly {
*/
audioFilePath?: string;

/**
* Background Volume
*
* @see [Audio tracks]{@link https://github.com/mifi/editly#arbitrary-audio-tracks}
*/
backgroundAudioVolume?: string | number;

/**
* Loop the audio track if it is shorter than video?
*
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async function Editly(config = {}) {
fps: requestedFps,
defaults = {},
audioFilePath: backgroundAudioPath,
backgroundAudioVolume,
loopAudio,
keepSourceAudio,
allowRemoteRequests,
Expand All @@ -58,7 +59,7 @@ async function Editly(config = {}) {
assert(outPath, 'Please provide an output path');
assert(clipsIn.length > 0, 'Please provide at least 1 clip');

const { clips, arbitraryAudio } = await parseConfig({ defaults, clips: clipsIn, arbitraryAudio: arbitraryAudioIn, backgroundAudioPath, loopAudio, allowRemoteRequests, ffprobePath });
const { clips, arbitraryAudio } = await parseConfig({ defaults, clips: clipsIn, arbitraryAudio: arbitraryAudioIn, backgroundAudioPath, backgroundAudioVolume, loopAudio, allowRemoteRequests, ffprobePath });
if (verbose) console.log('Calculated', JSON5.stringify({ clips, arbitraryAudio }, null, 2));

const outDir = dirname(outPath);
Expand Down
4 changes: 2 additions & 2 deletions parseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function validateArbitraryAudio(audio, allowRemoteRequests) {
}
}

export default async function parseConfig({ defaults: defaultsIn = {}, clips, arbitraryAudio: arbitraryAudioIn, backgroundAudioPath, loopAudio, allowRemoteRequests, ffprobePath }) {
export default async function parseConfig({ defaults: defaultsIn = {}, clips, arbitraryAudio: arbitraryAudioIn, backgroundAudioPath, backgroundAudioVolume, loopAudio, allowRemoteRequests, ffprobePath }) {
const defaults = {
duration: 4,
...defaultsIn,
Expand Down Expand Up @@ -278,7 +278,7 @@ export default async function parseConfig({ defaults: defaultsIn = {}, clips, ar
// Audio can either come from `audioFilePath`, `audio` or from "detached" audio layers from clips
const arbitraryAudio = [
// Background audio is treated just like arbitrary audio
...(backgroundAudioPath ? [{ path: backgroundAudioPath, mixVolume: 1, loop: loopAudio ? -1 : 0 }] : []),
...(backgroundAudioPath ? [{ path: backgroundAudioPath, mixVolume: backgroundAudioVolume != null ? backgroundAudioVolume : 1, loop: loopAudio ? -1 : 0 }] : []),
...arbitraryAudioIn,
...clipDetachedAudio,
];
Expand Down

0 comments on commit dea54b1

Please sign in to comment.