{"record":{"id":"810b59311d3b767e","repo":"Mintplex-Labs/anything-llm","slug":"ffmpeg-candidate-path-is-not-valid-ffmpeg-binary","errorCode":null,"errorMessage":"FFMPEG candidate path is not valid ffmpeg binary.","messagePattern":"FFMPEG candidate path is not valid ffmpeg binary\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"collector/utils/WhisperProviders/ffmpeg/index.js","lineNumber":43,"sourceCode":"\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\n   * @returns {boolean}\n   */","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/WhisperProviders/ffmpeg/index.js#L25-L61","documentation":"Thrown (and caught/logged) when `which` returns a path but isValidFFMPEG returns false — the file does not exist, is not executable, or running `\"<path>\" -version` exits non-zero. Like error 20 it is swallowed by the surrounding try/catch and the caller sees \"FFMPEG binary not found.\" instead.","triggerScenarios":"isValidFFMPEG fails: !fs.existsSync(pathToTest) is true, or `execSync(`\"${pathToTest}\" -version`)` throws (broken symlink, non-executable, wrong binary, ffmpeg crash on -version).","commonSituations":"ffmpeg was uninstalled leaving a dangling symlink; execute permission stripped (chmod -x); a partial/broken ffmpeg build; PATH points to a wrapper script that errors out.","solutions":["Inspect the path `which ffmpeg` prints: `ls -la <path>` and run `<path> -version` manually.","Reinstall ffmpeg cleanly: `brew reinstall ffmpeg` or `apt install --reinstall ffmpeg`.","Remove stale symlinks or PATH entries pointing at dead locations."],"exampleFix":"// before\nexecSync(`\"${pathToTest}\" -version`, { encoding: \"utf8\", stdio: \"pipe\" });\n\n// after — capture why validation failed for diagnostics\ntry {\n  execSync(`\"${pathToTest}\" -version`, { encoding: \"utf8\", stdio: \"pipe\" });\n  return true;\n} catch (e) {\n  console.warn(`ffmpeg at ${pathToTest} failed -version: ${e.message}`);\n  return false;\n}","handlingStrategy":"validation","validationCode":"const fs = require(\"fs\");\nconst { execSync } = require(\"child_process\");\nfunction ffmpegBinaryWorks(candidate) {\n  if (!candidate || !fs.existsSync(candidate)) return false;\n  try {\n    execSync(`\"${candidate}\" -version`, { encoding: \"utf8\", stdio: \"pipe\" });\n    return true;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { await ffmpeg.ffmpegPath(); }\ncatch (e) {\n  // 21 is swallowed; caller sees error 22\n  if (e.message === \"FFMPEG binary not found.\") { /* reinstall / fix PATH */ }\n  throw e;\n}","preventionTips":["Run the resolved ffmpeg path with -version during setup.","Avoid symlinks into version-managed directories that can dangle.","Pin ffmpeg to a known-good install location."],"tags":["ffmpeg","audio","binary-resolution","validation"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}