diff --git a/index.js b/index.js index b86a54f..a5f86e1 100644 --- a/index.js +++ b/index.js @@ -33,6 +33,9 @@ module.exports = async (config = {}) => { fps: requestedFps, defaults: defaultsIn = {}, audioFilePath: audioFilePathIn, + + ffmpegPath = 'ffmpeg', + ffprobePath = 'ffprobe', } = config; const isGif = outPath.toLowerCase().endsWith('.gif'); @@ -130,7 +133,7 @@ module.exports = async (config = {}) => { if (type === 'video') { const { cutFrom: cutFromIn, cutTo: cutToIn, path } = layer; - const fileInfo = await readFileInfo(path); + const fileInfo = await readFileInfo(ffprobePath, path); const { duration: fileDuration, width: widthIn, height: heightIn, framerateStr, rotation } = fileInfo; let cutFrom; let cutTo; @@ -299,7 +302,7 @@ module.exports = async (config = {}) => { ...outputArgs, ]; if (verbose) console.log('ffmpeg', args.join(' ')); - return execa('ffmpeg', args, { encoding: null, buffer: false, stdin: 'pipe', stdout: process.stdout, stderr: process.stderr }); + return execa(ffmpegPath, args, { encoding: null, buffer: false, stdin: 'pipe', stdout: process.stdout, stderr: process.stderr }); } let outProcess; @@ -326,7 +329,7 @@ module.exports = async (config = {}) => { const getTransitionFromClip = () => clips[transitionFromClipId]; const getTransitionToClip = () => clips[getTransitionToClipId()]; - const getSource = (clip, clipIndex) => createFrameSource({ clip, clipIndex, width, height, channels, verbose, enableFfmpegLog, framerateStr }); + const getSource = (clip, clipIndex) => createFrameSource({ clip, clipIndex, width, height, channels, verbose, ffmpegPath, enableFfmpegLog, framerateStr }); const getTransitionToSource = async () => (getTransitionToClip() && getSource(getTransitionToClip(), getTransitionToClipId())); frameSource1 = await getSource(getTransitionFromClip(), transitionFromClipId); diff --git a/sources/frameSource.js b/sources/frameSource.js index dd4b23e..cdfe545 100644 --- a/sources/frameSource.js +++ b/sources/frameSource.js @@ -6,7 +6,7 @@ const createVideoFrameSource = require('./videoFrameSource'); const { createGlFrameSource } = require('./glFrameSource'); -async function createFrameSource({ clip, clipIndex, width, height, channels, verbose, enableFfmpegLog, framerateStr }) { +async function createFrameSource({ clip, clipIndex, width, height, channels, verbose, ffmpegPath, enableFfmpegLog, framerateStr }) { const { layers, duration } = clip; const frameSources = await pMap(layers, async (layer, layerIndex) => { @@ -29,7 +29,7 @@ async function createFrameSource({ clip, clipIndex, width, height, channels, ver const createFrameSourceFunc = frameSourceFuncs[type]; - return createFrameSourceFunc({ width, height, duration, channels, verbose, enableFfmpegLog, framerateStr, params }); + return createFrameSourceFunc({ ffmpegPath, width, height, duration, channels, verbose, enableFfmpegLog, framerateStr, params }); }, { concurrency: 1 }); async function readNextFrame(...args) { diff --git a/sources/videoFrameSource.js b/sources/videoFrameSource.js index e22ced9..5c6859c 100644 --- a/sources/videoFrameSource.js +++ b/sources/videoFrameSource.js @@ -42,7 +42,7 @@ module.exports = async ({ width, height, channels, framerateStr, verbose, enable ]; if (verbose) console.log(args.join(' ')); - const ps = execa('ffmpeg', args, { encoding: null, buffer: false, stdin: 'ignore', stdout: 'pipe', stderr: process.stderr }); + const ps = execa(ffmpegPath, args, { encoding: null, buffer: false, stdin: 'ignore', stdout: 'pipe', stderr: process.stderr }); const stream = ps.stdout; diff --git a/util.js b/util.js index 2dd746d..2116187 100644 --- a/util.js +++ b/util.js @@ -10,8 +10,8 @@ function parseFps(fps) { return undefined; } -async function readFileInfo(p) { - const { stdout } = await execa('ffprobe', [ +async function readFileInfo(ffprobePath, p) { + const { stdout } = await execa(ffprobePath, [ '-select_streams', 'v:0', '-show_entries', 'stream', '-of', 'json', p, ]); const json = JSON.parse(stdout);