@@ -7,7 +7,6 @@ import { join } from "node:path"
77import { PassThrough } from "node:stream"
88
99const dbg = debug ( "ffmpeg-stream" )
10- const { FFMPEG_PATH = "ffmpeg" } = process . env
1110const 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