Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

Node bindings to ffmpeg command, exposing stream based API.

[CHANGELOG](CHANGELOG.md)

**Note:** ffmpeg must be installed and available in `PATH`.
You can set a custom ffmpeg path via `FFMPEG_PATH` environment variable (default is just `ffmpeg`).
> [!NOTE]
> FFmpeg must be installed and available in `PATH`.
> You can set a custom ffmpeg path via an argument (default is just `ffmpeg`).

## Examples

Expand Down
19 changes: 14 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { join } from "node:path"
import { PassThrough } from "node:stream"

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

/**
Expand Down Expand Up @@ -100,8 +99,6 @@ function getArgs(options) {
/**
* A class which wraps a FFmpeg process.
*
* Remember to call {@link Converter.run} to start the conversion.
*
* @example
*
* ```js
Expand Down Expand Up @@ -139,6 +136,18 @@ export class Converter {
*/
killed = false

/**
* Initializes the converter.
*
* Remember to call {@link Converter.run} to actually start the FFmpeg process.
*
* @param {string} [ffmpegPath] Path to the FFmpeg executable. (default: `"ffmpeg"`)
*/
constructor(ffmpegPath = "ffmpeg") {
/** @private */
this.ffmpegPath = ffmpegPath
}

/**
* Defines an FFmpeg input file.
*
Expand Down Expand Up @@ -377,9 +386,9 @@ export class Converter {

const command = this.getSpawnArgs()
const stdio = this.getStdioArg()
dbg(`spawn: ${FFMPEG_PATH} ${command.join(" ")}`)
dbg(`spawn: ${this.ffmpegPath} ${command.join(" ")}`)
dbg(`spawn stdio: ${stdio.join(" ")}`)
this.process = spawn(FFMPEG_PATH, command, { stdio })
this.process = spawn(this.ffmpegPath, command, { stdio })
const finished = this.handleProcess()

for (const pipe of this.pipes) {
Expand Down