[PR #2391] [MERGED] Add a binary manager that finds ffmpeg and ffprobe and installs them if not found #3705

Closed
opened 2026-04-25 00:16:43 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/2391
Author: @mikiher
Created: 12/5/2023
Status: Merged
Merged: 1/2/2024
Merged by: @advplyr

Base: masterHead: binary-manager


📝 Commits (10+)

  • b1b325d Add ffbinaries dependency
  • 2e989fb Add BinaryManager
  • c074c83 Remove semicolons from test
  • 1ce1904 Add ffbinaries lib
  • 61a0126 Remove ffbinaries dependency
  • 898b072 Merge branch 'advplyr:master' into binary-manager
  • 67ccd2c Fix test after switching to libs/ffbinaries
  • 699a658 Remove debug printing from libs/ffbinaries
  • 18b3ab5 Revert package-lock updates
  • 09282a9 Remove all callbacks and refactor spaghetti code in downloadUrls

📊 Changes

6 files changed (+681 additions, -0 deletions)

View changed files

📝 .gitignore (+2 -0)
📝 server/Server.js (+7 -0)
server/libs/ffbinaries/index.js (+315 -0)
server/managers/BinaryManager.js (+74 -0)
📝 server/utils/fileUtils.js (+19 -0)
test/server/managers/BinaryManager.test.js (+264 -0)

📄 Description

In continuation of our discussion #2352, I created a binary manager that makes sure the ffmpeg/ffprobe binary dependencies exist, and if they don't it installs them.

A few implementation details:

  • The binaries are not bundled with audiobookshelf (and they're also not bundled as pkg assets). Instead I've added a dependency on the ffbinaries package, which can programmatically download and install them if needed. This is good since:
    • it doesn't increase the pkg executable size (which is already quite large, ~54MB for Win64)
    • it is probably better from a legal perspective because of GPL implications.
  • The binary manager tries to find the binaries in a number of ways, and only installs if it cannot find it. It tries to:
    • Check the FFMPEG_PATH/FFPROBE_PATH environment variables, if defined.
    • Use which to check if it's somewhere in PATH
    • Checks the main install path (see below)
    • Checks the alt install path (see below)
  • If the binary manager does not find the binaries, it tries to install them in one of two paths:
    • the main install path, which is the same directory in which the audiobookshelf binary is installed, if it's pkged, or global.appRoot, if it's not.
    • in case the main install path is not writable (due to permissions), an alternative install path is used, which is the audiobookshelf config directory (which should always exist and be writable).
  • The binary manager is instantiated and initialized with the other managers, in server.js

This should work on all platforms, however I could only test on Win64 (I tested both pkged and non-pkged).
If you don't want to use this on non-windows platforms, we can restrict it to windows only, but I think we should really just make sure it it works on the other platforms.

So with this, we can drop the requirement to install ffmpeg in advance or bundle it with installers. For windows, people just need to download the binary and put it in whatever directory they want.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/2391 **Author:** [@mikiher](https://github.com/mikiher) **Created:** 12/5/2023 **Status:** ✅ Merged **Merged:** 1/2/2024 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `binary-manager` --- ### 📝 Commits (10+) - [`b1b325d`](https://github.com/advplyr/audiobookshelf/commit/b1b325d00b3595b6b9b77d5fbc5e4259a18ec1ba) Add ffbinaries dependency - [`2e989fb`](https://github.com/advplyr/audiobookshelf/commit/2e989fbe83f00691ed0a955fe82d0e1bf1b1b7df) Add BinaryManager - [`c074c83`](https://github.com/advplyr/audiobookshelf/commit/c074c835d4c9eeefc008ce95aa4141164a072f5d) Remove semicolons from test - [`1ce1904`](https://github.com/advplyr/audiobookshelf/commit/1ce1904c892e79f6de8a901d72fe3ad5746a3a3e) Add ffbinaries lib - [`61a0126`](https://github.com/advplyr/audiobookshelf/commit/61a0126278853d4661ed7418cd0233274a78e31c) Remove ffbinaries dependency - [`898b072`](https://github.com/advplyr/audiobookshelf/commit/898b072e68bc2b6edd22b4febc230bf1ac4b4c70) Merge branch 'advplyr:master' into binary-manager - [`67ccd2c`](https://github.com/advplyr/audiobookshelf/commit/67ccd2c1fb9a9ebc8378d11de09bd9d7a6477578) Fix test after switching to libs/ffbinaries - [`699a658`](https://github.com/advplyr/audiobookshelf/commit/699a658df930d3d750f022965c542ec19c0b4221) Remove debug printing from libs/ffbinaries - [`18b3ab5`](https://github.com/advplyr/audiobookshelf/commit/18b3ab561009774e5e6f135af2bb4ab508a3a5ef) Revert package-lock updates - [`09282a9`](https://github.com/advplyr/audiobookshelf/commit/09282a9a62380c5e58be58a19eb24535798a0c01) Remove all callbacks and refactor spaghetti code in downloadUrls ### 📊 Changes **6 files changed** (+681 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+2 -0) 📝 `server/Server.js` (+7 -0) ➕ `server/libs/ffbinaries/index.js` (+315 -0) ➕ `server/managers/BinaryManager.js` (+74 -0) 📝 `server/utils/fileUtils.js` (+19 -0) ➕ `test/server/managers/BinaryManager.test.js` (+264 -0) </details> ### 📄 Description In continuation of our discussion #2352, I created a binary manager that makes sure the ffmpeg/ffprobe binary dependencies exist, and if they don't it installs them. A few implementation details: - The binaries are not bundled with audiobookshelf (and they're also not bundled as pkg assets). Instead I've added a dependency on the ffbinaries package, which can programmatically download and install them if needed. This is good since: - it doesn't increase the pkg executable size (which is already quite large, ~54MB for Win64) - it is probably better from a legal perspective because of GPL implications. - The binary manager tries to find the binaries in a number of ways, and only installs if it cannot find it. It tries to: - Check the FFMPEG_PATH/FFPROBE_PATH environment variables, if defined. - Use which to check if it's somewhere in PATH - Checks the main install path (see below) - Checks the alt install path (see below) - If the binary manager does not find the binaries, it tries to install them in one of two paths: - the main install path, which is the same directory in which the audiobookshelf binary is installed, if it's pkged, or global.appRoot, if it's not. - in case the main install path is not writable (due to permissions), an alternative install path is used, which is the audiobookshelf config directory (which should always exist and be writable). - The binary manager is instantiated and initialized with the other managers, in server.js This should work on all platforms, however I could only test on Win64 (I tested both pkged and non-pkged). If you don't want to use this on non-windows platforms, we can restrict it to windows only, but I think we should really just make sure it it works on the other platforms. So with this, we can drop the requirement to install ffmpeg in advance or bundle it with installers. For windows, people just need to download the binary and put it in whatever directory they want. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:16:43 +02:00
adam closed this issue 2026-04-25 00:16:44 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3705