Skip to content

Commit af04d72

Browse files
authored
feat!: pass custom ffmpeg path via argument (#63)
BREAKING CHANGE: passing ffmpeg path via env var is not supported anymore
1 parent 4162fb3 commit af04d72

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
Node bindings to ffmpeg command, exposing stream based API.
77

8-
[CHANGELOG](CHANGELOG.md)
9-
10-
**Note:** ffmpeg must be installed and available in `PATH`.
11-
You can set a custom ffmpeg path via `FFMPEG_PATH` environment variable (default is just `ffmpeg`).
8+
> [!NOTE]
9+
> FFmpeg must be installed and available in `PATH`.
10+
> You can set a custom ffmpeg path via an argument (default is just `ffmpeg`).
1211
1312
## Examples
1413

lib/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { join } from "node:path"
77
import { PassThrough } from "node:stream"
88

99
const dbg = debug("ffmpeg-stream")
10-
const { FFMPEG_PATH = "ffmpeg" } = process.env
1110
const EXIT_CODES = [0, 255]
1211

1312
/**
@@ -100,8 +99,6 @@ function getArgs(options) {
10099
/**
101100
* A class which wraps a FFmpeg process.
102101
*
103-
* Remember to call {@link Converter.run} to start the conversion.
104-
*
105102
* @example
106103
*
107104
* ```js
@@ -139,6 +136,18 @@ export class Converter {
139136
*/
140137
killed = false
141138

139+
/**
140+
* Initializes the converter.
141+
*
142+
* Remember to call {@link Converter.run} to actually start the FFmpeg process.
143+
*
144+
* @param {string} [ffmpegPath] Path to the FFmpeg executable. (default: `"ffmpeg"`)
145+
*/
146+
constructor(ffmpegPath = "ffmpeg") {
147+
/** @private */
148+
this.ffmpegPath = ffmpegPath
149+
}
150+
142151
/**
143152
* Defines an FFmpeg input file.
144153
*
@@ -377,9 +386,9 @@ export class Converter {
377386

378387
const command = this.getSpawnArgs()
379388
const stdio = this.getStdioArg()
380-
dbg(`spawn: ${FFMPEG_PATH} ${command.join(" ")}`)
389+
dbg(`spawn: ${this.ffmpegPath} ${command.join(" ")}`)
381390
dbg(`spawn stdio: ${stdio.join(" ")}`)
382-
this.process = spawn(FFMPEG_PATH, command, { stdio })
391+
this.process = spawn(this.ffmpegPath, command, { stdio })
383392
const finished = this.handleProcess()
384393

385394
for (const pipe of this.pipes) {

0 commit comments

Comments
 (0)