{"record":{"id":"6579725735a3d24a","repo":"Mintplex-Labs/anything-llm","slug":"ffmpeg-candidate-path-not-found","errorCode":null,"errorMessage":"FFMPEG candidate path not found.","messagePattern":"FFMPEG candidate path not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"collector/utils/WhisperProviders/ffmpeg/index.js","lineNumber":41,"sourceCode":"    console.log(`\\x1b[35m[FFMPEG]\\x1b[0m ${text}`, ...args);\n  }\n\n  /**\n   * Locates ffmpeg binary.\n   * Uses fix-path on non-Windows platforms to ensure we can find ffmpeg.\n   *\n   * @returns {Promise<string>} Path to ffmpeg binary\n   * @throws {Error}\n   */\n  async ffmpegPath() {\n    if (this._ffmpegPath) return this._ffmpegPath;\n    await patchShellEnvironmentPath();\n\n    try {\n      const which = process.platform === \"win32\" ? \"where\" : \"which\";\n      const result = execSync(`${which} ffmpeg`, { encoding: \"utf8\" }).trim();\n      const candidatePath = result?.split(\"\\n\")?.[0]?.trim();\n      if (!candidatePath) throw new Error(\"FFMPEG candidate path not found.\");\n      if (!this.isValidFFMPEG(candidatePath))\n        throw new Error(\"FFMPEG candidate path is not valid ffmpeg binary.\");\n\n      this.log(`Found FFMPEG binary at ${candidatePath}`);\n      this._ffmpegPath = candidatePath;\n      return this._ffmpegPath;\n    } catch (error) {\n      this.log(error.message);\n    }\n\n    throw new Error(\"FFMPEG binary not found.\");\n  }\n\n  /**\n   * Validates that path points to a valid ffmpeg binary.\n   * Runs ffmpeg -version command.\n   *\n   * @param {string} pathToTest - Path of ffmpeg binary","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/WhisperProviders/ffmpeg/index.js#L23-L59","documentation":"Thrown (and immediately caught/logged) by FFMPEGWrapper.ffmpegPath() when `which ffmpeg`/`where ffmpeg` returns output but the first newline-split line is empty after trimming. Because the throw sits inside a try/catch, the message is only logged; the caller always receives the downstream \"FFMPEG binary not found.\" error instead. It is an internal diagnostic, not a propagated exception.","triggerScenarios":"`execSync(`${which} ffmpeg`)` returns only whitespace/newlines, so `result.split(\"\\n\")[0].trim()` yields an empty string and the `if (!candidatePath)` guard fires.","commonSituations":"A shell alias/function named ffmpeg that echoes nothing; a broken PATH entry that `which` resolves but prints blank; rare edge where `which` emits a bare newline; tampered PATH in a container.","solutions":["Install ffmpeg and confirm `which ffmpeg` prints a real path in the same shell the Node process uses.","If Node is GUI-launched, ensure PATH includes /opt/homebrew/bin and /usr/local/bin (patchShellEnvironmentPath already attempts this).","Set an explicit PATH or FFMPEG location in the process environment before invoking Whisper."],"exampleFix":"// before\nconst result = execSync(`${which} ffmpeg`, { encoding: \"utf8\" }).trim();\nconst candidatePath = result?.split(\"\\n\")?.[0]?.trim();\n\n// after — fall back to a known binary location\nlet candidatePath = result?.split(\"\\n\")?.[0]?.trim();\nif (!candidatePath && fs.existsSync(\"/usr/local/bin/ffmpeg\")) {\n  candidatePath = \"/usr/local/bin/ffmpeg\";\n}","handlingStrategy":"validation","validationCode":"const { execSync } = require(\"child_process\");\nfunction ffmpegOnPath() {\n  try {\n    const out = execSync(`${process.platform === \"win32\" ? \"where\" : \"which\"} ffmpeg`, {\n      encoding: \"utf8\", stdio: \"pipe\"\n    }).trim();\n    return out.split(\"\\n\")[0].trim().length > 0;\n  } catch { return false; }\n}\n// before enabling Whisper: if (!ffmpegOnPath()) warn user;","typeGuard":null,"tryCatchPattern":"try {\n  const p = await ffmpeg.ffmpegPath();\n} catch (e) {\n  // 20 is swallowed; caller sees error 22 \"FFMPEG binary not found.\"\n  if (e.message === \"FFMPEG binary not found.\") { /* guide install */ }\n  throw e;\n}","preventionTips":["Install ffmpeg before enabling local Whisper transcription.","Launch Node from a login shell so PATH includes the binary directory.","Verify with `which ffmpeg` in the exact environment the app runs in."],"tags":["ffmpeg","audio","binary-resolution","environment"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}