Browse Source

allow settings ffmpegpath

pull/44/head
Mikael Finstad 6 years ago
parent
commit
143dd03eb7
  1. 9
      index.js
  2. 4
      sources/frameSource.js
  3. 2
      sources/videoFrameSource.js
  4. 4
      util.js

9
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);

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

2
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;

4
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);

Loading…
Cancel
Save