ffmpeg: Support for system-wide FFmpeg installations
This commit is contained in:
@@ -2,6 +2,7 @@ const path = require('path');
|
|||||||
const process = require('process');
|
const process = require('process');
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
function parse_duration(str) {
|
function parse_duration(str) {
|
||||||
// Duration is in the form HH:MM:SS.fraction
|
// Duration is in the form HH:MM:SS.fraction
|
||||||
@@ -14,13 +15,20 @@ function parse_duration(str) {
|
|||||||
|
|
||||||
class ffmpeg {
|
class ffmpeg {
|
||||||
constructor(ffpath) {
|
constructor(ffpath) {
|
||||||
// Figure out the location of FFmpeg
|
this.bin = {};
|
||||||
if (!ffpath)
|
this.bin.ffmpeg = "ffmpeg";
|
||||||
ffpath = process.cwd();
|
this.bin.ffprobe = "ffprobe";
|
||||||
this.bin = {
|
if (os.platform() == "win32") { // Windows has special behavior - system installed FFmpeg is rare.
|
||||||
ffmpeg: path.join(ffpath, "bin/ffmpeg.exe"),
|
let ffmpeg_local = path.join((ffpath ? ffpath : process.cwd()), "bin/ffmpeg.exe");
|
||||||
ffprobe: path.join(ffpath, "bin/ffprobe.exe")
|
if (fs.existsSync(ffmpeg_local)) {
|
||||||
};
|
this.bin.ffmpeg = ffmpeg_local;
|
||||||
|
}
|
||||||
|
|
||||||
|
let ffprobe_local = path.join((ffpath ? ffpath : process.cwd()), "bin/ffprobe.exe");
|
||||||
|
if (fs.existsSync(ffmpeg_local)) {
|
||||||
|
this.bin.ffmpeg = ffprobe_local;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_probeParse(buffer) {
|
_probeParse(buffer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user