@fredlackey/devutils 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/README.md +5 -5
  2. package/package.json +1 -1
  3. package/src/commands/install.js +374 -36
  4. package/src/installs/adobe-creative-cloud.js +527 -25
  5. package/src/installs/adobe-creative-cloud.md +605 -0
  6. package/src/installs/appcleaner.js +303 -26
  7. package/src/installs/appcleaner.md +699 -0
  8. package/src/installs/apt-transport-https.js +390 -0
  9. package/src/installs/apt-transport-https.md +678 -0
  10. package/src/installs/atomicparsley.js +624 -26
  11. package/src/installs/atomicparsley.md +795 -0
  12. package/src/installs/aws-cli.js +779 -26
  13. package/src/installs/aws-cli.md +727 -0
  14. package/src/installs/balena-etcher.js +688 -26
  15. package/src/installs/balena-etcher.md +761 -0
  16. package/src/installs/bambu-studio.js +912 -26
  17. package/src/installs/bambu-studio.md +780 -0
  18. package/src/installs/bash-completion.js +554 -23
  19. package/src/installs/bash-completion.md +833 -0
  20. package/src/installs/bash.js +399 -26
  21. package/src/installs/bash.md +993 -0
  22. package/src/installs/beyond-compare.js +585 -26
  23. package/src/installs/beyond-compare.md +813 -0
  24. package/src/installs/build-essential.js +511 -26
  25. package/src/installs/build-essential.md +977 -0
  26. package/src/installs/ca-certificates.js +618 -0
  27. package/src/installs/ca-certificates.md +937 -0
  28. package/src/installs/caffeine.js +490 -26
  29. package/src/installs/caffeine.md +839 -0
  30. package/src/installs/camtasia.js +577 -25
  31. package/src/installs/camtasia.md +762 -0
  32. package/src/installs/chatgpt.js +458 -26
  33. package/src/installs/chatgpt.md +814 -0
  34. package/src/installs/chocolatey.js +447 -0
  35. package/src/installs/chocolatey.md +661 -0
  36. package/src/installs/chrome-canary.js +472 -26
  37. package/src/installs/chrome-canary.md +641 -0
  38. package/src/installs/chromium.js +645 -26
  39. package/src/installs/chromium.md +838 -0
  40. package/src/installs/claude-code.js +558 -26
  41. package/src/installs/claude-code.md +1173 -0
  42. package/src/installs/curl.js +361 -26
  43. package/src/installs/curl.md +714 -0
  44. package/src/installs/cursor.js +561 -26
  45. package/src/installs/cursor.md +970 -0
  46. package/src/installs/dbschema.js +674 -26
  47. package/src/installs/dbschema.md +925 -0
  48. package/src/installs/dependencies.md +435 -0
  49. package/src/installs/development-tools.js +600 -0
  50. package/src/installs/development-tools.md +977 -0
  51. package/src/installs/docker.js +1010 -25
  52. package/src/installs/docker.md +1109 -0
  53. package/src/installs/drawio.js +1001 -26
  54. package/src/installs/drawio.md +795 -0
  55. package/src/installs/elmedia-player.js +328 -25
  56. package/src/installs/elmedia-player.md +556 -0
  57. package/src/installs/ffmpeg.js +870 -25
  58. package/src/installs/ffmpeg.md +852 -0
  59. package/src/installs/file.js +464 -0
  60. package/src/installs/file.md +987 -0
  61. package/src/installs/gemini-cli.js +793 -26
  62. package/src/installs/gemini-cli.md +1153 -0
  63. package/src/installs/git.js +382 -26
  64. package/src/installs/git.md +907 -0
  65. package/src/installs/gitego.js +931 -26
  66. package/src/installs/gitego.md +1172 -0
  67. package/src/installs/go.js +913 -26
  68. package/src/installs/go.md +958 -0
  69. package/src/installs/google-chrome.js +801 -25
  70. package/src/installs/google-chrome.md +862 -0
  71. package/src/installs/gpg.js +412 -73
  72. package/src/installs/gpg.md +1056 -0
  73. package/src/installs/homebrew.js +1015 -26
  74. package/src/installs/homebrew.md +988 -0
  75. package/src/installs/imageoptim.js +950 -26
  76. package/src/installs/imageoptim.md +1119 -0
  77. package/src/installs/installers.json +2297 -0
  78. package/src/installs/jq.js +382 -26
  79. package/src/installs/jq.md +809 -0
  80. package/src/installs/keyboard-maestro.js +701 -26
  81. package/src/installs/keyboard-maestro.md +825 -0
  82. package/src/installs/latex.js +771 -26
  83. package/src/installs/latex.md +1095 -0
  84. package/src/installs/lftp.js +338 -26
  85. package/src/installs/lftp.md +907 -0
  86. package/src/installs/lsb-release.js +346 -0
  87. package/src/installs/lsb-release.md +814 -0
  88. package/src/installs/messenger.js +829 -26
  89. package/src/installs/messenger.md +900 -0
  90. package/src/installs/microsoft-office.js +550 -26
  91. package/src/installs/microsoft-office.md +760 -0
  92. package/src/installs/microsoft-teams.js +782 -25
  93. package/src/installs/microsoft-teams.md +886 -0
  94. package/src/installs/node.js +886 -26
  95. package/src/installs/node.md +1153 -0
  96. package/src/installs/nordpass.js +698 -26
  97. package/src/installs/nordpass.md +921 -0
  98. package/src/installs/nvm.js +977 -26
  99. package/src/installs/nvm.md +1057 -0
  100. package/src/installs/openssh.js +734 -64
  101. package/src/installs/openssh.md +1056 -0
  102. package/src/installs/pandoc.js +644 -26
  103. package/src/installs/pandoc.md +1036 -0
  104. package/src/installs/pinentry.js +492 -26
  105. package/src/installs/pinentry.md +1142 -0
  106. package/src/installs/pngyu.js +851 -26
  107. package/src/installs/pngyu.md +896 -0
  108. package/src/installs/postman.js +781 -26
  109. package/src/installs/postman.md +940 -0
  110. package/src/installs/procps.js +425 -0
  111. package/src/installs/procps.md +851 -0
  112. package/src/installs/safari-tech-preview.js +355 -25
  113. package/src/installs/safari-tech-preview.md +533 -0
  114. package/src/installs/sfnt2woff.js +640 -26
  115. package/src/installs/sfnt2woff.md +795 -0
  116. package/src/installs/shellcheck.js +463 -26
  117. package/src/installs/shellcheck.md +1005 -0
  118. package/src/installs/slack.js +722 -25
  119. package/src/installs/slack.md +865 -0
  120. package/src/installs/snagit.js +566 -25
  121. package/src/installs/snagit.md +844 -0
  122. package/src/installs/software-properties-common.js +372 -0
  123. package/src/installs/software-properties-common.md +805 -0
  124. package/src/installs/spotify.js +858 -25
  125. package/src/installs/spotify.md +901 -0
  126. package/src/installs/studio-3t.js +803 -26
  127. package/src/installs/studio-3t.md +918 -0
  128. package/src/installs/sublime-text.js +780 -25
  129. package/src/installs/sublime-text.md +914 -0
  130. package/src/installs/superwhisper.js +687 -25
  131. package/src/installs/superwhisper.md +630 -0
  132. package/src/installs/tailscale.js +727 -26
  133. package/src/installs/tailscale.md +1100 -0
  134. package/src/installs/tar.js +389 -0
  135. package/src/installs/tar.md +946 -0
  136. package/src/installs/termius.js +780 -26
  137. package/src/installs/termius.md +844 -0
  138. package/src/installs/terraform.js +761 -26
  139. package/src/installs/terraform.md +899 -0
  140. package/src/installs/tidal.js +752 -25
  141. package/src/installs/tidal.md +864 -0
  142. package/src/installs/tmux.js +328 -26
  143. package/src/installs/tmux.md +1030 -0
  144. package/src/installs/tree.js +393 -26
  145. package/src/installs/tree.md +833 -0
  146. package/src/installs/unzip.js +460 -0
  147. package/src/installs/unzip.md +879 -0
  148. package/src/installs/vim.js +403 -26
  149. package/src/installs/vim.md +1040 -0
  150. package/src/installs/vlc.js +803 -26
  151. package/src/installs/vlc.md +927 -0
  152. package/src/installs/vscode.js +825 -26
  153. package/src/installs/vscode.md +1002 -0
  154. package/src/installs/wget.js +415 -0
  155. package/src/installs/wget.md +791 -0
  156. package/src/installs/whatsapp.js +710 -25
  157. package/src/installs/whatsapp.md +854 -0
  158. package/src/installs/winpty.js +352 -0
  159. package/src/installs/winpty.md +620 -0
  160. package/src/installs/woff2.js +535 -26
  161. package/src/installs/woff2.md +977 -0
  162. package/src/installs/wsl.js +572 -0
  163. package/src/installs/wsl.md +699 -0
  164. package/src/installs/xcode-clt.js +520 -0
  165. package/src/installs/xcode-clt.md +351 -0
  166. package/src/installs/xcode.js +542 -26
  167. package/src/installs/xcode.md +573 -0
  168. package/src/installs/yarn.js +806 -26
  169. package/src/installs/yarn.md +1074 -0
  170. package/src/installs/yq.js +636 -26
  171. package/src/installs/yq.md +944 -0
  172. package/src/installs/yt-dlp.js +683 -26
  173. package/src/installs/yt-dlp.md +946 -0
  174. package/src/installs/yum-utils.js +297 -0
  175. package/src/installs/yum-utils.md +648 -0
  176. package/src/installs/zoom.js +740 -25
  177. package/src/installs/zoom.md +884 -0
  178. package/src/scripts/README.md +567 -45
  179. package/src/scripts/STATUS.md +208 -0
  180. package/src/scripts/afk.js +395 -7
  181. package/src/scripts/backup-all.js +731 -9
  182. package/src/scripts/backup-source.js +711 -8
  183. package/src/scripts/brewd.js +373 -7
  184. package/src/scripts/brewi.js +505 -9
  185. package/src/scripts/brewr.js +512 -9
  186. package/src/scripts/brews.js +462 -9
  187. package/src/scripts/brewu.js +488 -7
  188. package/src/scripts/c.js +185 -7
  189. package/src/scripts/ccurl.js +325 -8
  190. package/src/scripts/certbot-crontab-init.js +488 -8
  191. package/src/scripts/certbot-init.js +641 -9
  192. package/src/scripts/ch.js +339 -7
  193. package/src/scripts/claude-danger.js +253 -8
  194. package/src/scripts/clean-dev.js +419 -8
  195. package/src/scripts/clear-dns-cache.js +525 -7
  196. package/src/scripts/clone.js +417 -7
  197. package/src/scripts/code-all.js +420 -7
  198. package/src/scripts/count-files.js +195 -8
  199. package/src/scripts/count-folders.js +195 -8
  200. package/src/scripts/count.js +248 -8
  201. package/src/scripts/d.js +203 -7
  202. package/src/scripts/datauri.js +373 -8
  203. package/src/scripts/delete-files.js +363 -7
  204. package/src/scripts/docker-clean.js +410 -8
  205. package/src/scripts/dp.js +426 -7
  206. package/src/scripts/e.js +375 -9
  207. package/src/scripts/empty-trash.js +497 -7
  208. package/src/scripts/evm.js +428 -9
  209. package/src/scripts/fetch-github-repos.js +441 -10
  210. package/src/scripts/get-channel.js +329 -8
  211. package/src/scripts/get-course.js +384 -11
  212. package/src/scripts/get-dependencies.js +290 -9
  213. package/src/scripts/get-folder.js +783 -10
  214. package/src/scripts/get-tunes.js +411 -10
  215. package/src/scripts/get-video.js +352 -9
  216. package/src/scripts/git-backup.js +561 -9
  217. package/src/scripts/git-clone.js +477 -9
  218. package/src/scripts/git-pup.js +303 -7
  219. package/src/scripts/git-push.js +380 -8
  220. package/src/scripts/h.js +607 -9
  221. package/src/scripts/hide-desktop-icons.js +483 -7
  222. package/src/scripts/hide-hidden-files.js +522 -7
  223. package/src/scripts/install-dependencies-from.js +440 -9
  224. package/src/scripts/ips.js +647 -10
  225. package/src/scripts/iso.js +354 -8
  226. package/src/scripts/killni.js +561 -7
  227. package/src/scripts/ll.js +451 -8
  228. package/src/scripts/local-ip.js +310 -8
  229. package/src/scripts/m.js +508 -8
  230. package/src/scripts/map.js +293 -8
  231. package/src/scripts/mkd.js +287 -7
  232. package/src/scripts/ncu-update-all.js +441 -8
  233. package/src/scripts/nginx-init.js +702 -12
  234. package/src/scripts/npmi.js +366 -7
  235. package/src/scripts/o.js +495 -8
  236. package/src/scripts/org-by-date.js +321 -7
  237. package/src/scripts/p.js +208 -7
  238. package/src/scripts/packages.js +313 -8
  239. package/src/scripts/path.js +209 -7
  240. package/src/scripts/ports.js +582 -8
  241. package/src/scripts/q.js +290 -8
  242. package/src/scripts/refresh-files.js +378 -10
  243. package/src/scripts/remove-smaller-files.js +500 -8
  244. package/src/scripts/rename-files-with-date.js +517 -9
  245. package/src/scripts/resize-image.js +523 -9
  246. package/src/scripts/rm-safe.js +653 -8
  247. package/src/scripts/s.js +525 -9
  248. package/src/scripts/set-git-public.js +349 -7
  249. package/src/scripts/show-desktop-icons.js +459 -7
  250. package/src/scripts/show-hidden-files.js +456 -7
  251. package/src/scripts/tpa.js +265 -8
  252. package/src/scripts/tpo.js +264 -7
  253. package/src/scripts/u.js +489 -7
  254. package/src/scripts/vpush.js +422 -8
  255. package/src/scripts/y.js +267 -7
  256. package/src/utils/common/os.js +94 -2
  257. package/src/utils/ubuntu/apt.js +13 -7
  258. package/src/utils/windows/choco.js +82 -26
  259. package/src/utils/windows/winget.js +89 -27
@@ -3,42 +3,887 @@
3
3
  /**
4
4
  * @fileoverview Install FFmpeg.
5
5
  * @module installs/ffmpeg
6
+ *
7
+ * FFmpeg is a complete, cross-platform solution for recording, converting,
8
+ * and streaming audio and video. It includes libavcodec (the leading audio/video
9
+ * codec library), libavformat (for muxing/demuxing into various container formats),
10
+ * and the ffmpeg command-line tool for transcoding multimedia files.
11
+ *
12
+ * This installer provides:
13
+ * - FFmpeg via Homebrew for macOS
14
+ * - FFmpeg via APT for Ubuntu/Debian and Raspberry Pi OS
15
+ * - FFmpeg via static builds for Amazon Linux (not available in standard repos)
16
+ * - FFmpeg via Chocolatey for Windows
17
+ * - FFmpeg via APT for WSL (Ubuntu)
18
+ * - FFmpeg via portable static builds for Git Bash
19
+ *
20
+ * IMPORTANT PLATFORM NOTES:
21
+ * - macOS: Installs via Homebrew formula with full codec support
22
+ * - Ubuntu/Debian: Installs from official APT repositories
23
+ * - Raspberry Pi OS: Installs from official APT repositories (ARM compatible)
24
+ * - Amazon Linux: Uses BtbN static builds (FFmpeg not in standard repos)
25
+ * - Windows: Installs via Chocolatey (essentials build)
26
+ * - WSL: Installs via APT within WSL environment
27
+ * - Git Bash: Downloads portable static builds from gyan.dev
6
28
  */
7
29
 
8
30
  const os = require('../utils/common/os');
31
+ const shell = require('../utils/common/shell');
32
+ const brew = require('../utils/macos/brew');
33
+ const apt = require('../utils/ubuntu/apt');
34
+ const choco = require('../utils/windows/choco');
35
+
36
+ /**
37
+ * The Homebrew formula name for FFmpeg on macOS.
38
+ * This installs FFmpeg with all common codecs (x264, x265, VP8/VP9, AV1, etc.).
39
+ */
40
+ const HOMEBREW_FORMULA_NAME = 'ffmpeg';
41
+
42
+ /**
43
+ * The APT package name for FFmpeg on Debian-based systems.
44
+ */
45
+ const APT_PACKAGE_NAME = 'ffmpeg';
46
+
47
+ /**
48
+ * The Chocolatey package name for FFmpeg on Windows.
49
+ * This installs the "essentials" build with commonly-used codecs.
50
+ */
51
+ const CHOCO_PACKAGE_NAME = 'ffmpeg';
52
+
53
+ /**
54
+ * Check if FFmpeg is installed by verifying the 'ffmpeg' command exists.
55
+ *
56
+ * This is a quick check that works across all platforms.
57
+ * Note that this only checks for the ffmpeg command, not ffprobe or ffplay.
58
+ *
59
+ * @returns {boolean} True if the ffmpeg command is available, false otherwise
60
+ */
61
+ function isFFmpegCommandAvailable() {
62
+ return shell.commandExists('ffmpeg');
63
+ }
64
+
65
+ /**
66
+ * Check if FFmpeg is installed and get the version.
67
+ *
68
+ * Executes 'ffmpeg -version' to verify FFmpeg is properly installed
69
+ * and operational. Returns the version string if successful.
70
+ *
71
+ * @returns {Promise<string|null>} FFmpeg version string, or null if not installed
72
+ */
73
+ async function getFFmpegVersion() {
74
+ // First check if the command exists to avoid unnecessary process spawning
75
+ if (!isFFmpegCommandAvailable()) {
76
+ return null;
77
+ }
78
+
79
+ // Execute ffmpeg -version to get version information
80
+ // The output format is typically: "ffmpeg version X.Y.Z Copyright..."
81
+ const result = await shell.exec('ffmpeg -version');
82
+ if (result.code === 0 && result.stdout) {
83
+ // Parse version from output like: "ffmpeg version 8.0.1 Copyright..."
84
+ // or "ffmpeg version N-XXXXX-gXXXXXXXXXX Copyright..." (for git builds)
85
+ const match = result.stdout.match(/ffmpeg version\s+([^\s]+)/);
86
+ return match ? match[1] : result.stdout.split('\n')[0].trim();
87
+ }
88
+ return null;
89
+ }
9
90
 
10
91
  /**
11
- * Install FFmpeg across supported platforms.
92
+ * Check if ffprobe is installed (companion tool to ffmpeg).
93
+ *
94
+ * ffprobe is typically installed alongside ffmpeg and is used to
95
+ * inspect media file properties.
96
+ *
97
+ * @returns {boolean} True if ffprobe is available, false otherwise
98
+ */
99
+ function isFFprobeAvailable() {
100
+ return shell.commandExists('ffprobe');
101
+ }
102
+
103
+ /**
104
+ * Install FFmpeg on macOS using Homebrew.
105
+ *
106
+ * Prerequisites:
107
+ * - macOS 12 (Monterey) or later
108
+ * - Homebrew package manager installed
109
+ * - Xcode Command Line Tools installed
110
+ *
111
+ * Homebrew installs FFmpeg with all its dependencies, including codecs
112
+ * for x264, x265, VP8/VP9, AV1, and various audio formats.
113
+ *
114
+ * @returns {Promise<void>}
115
+ * @throws {Error} If Homebrew is not installed or installation fails
116
+ */
117
+ async function install_macos() {
118
+ console.log('Checking if FFmpeg is already installed...');
119
+
120
+ // Check if FFmpeg is already installed
121
+ const existingVersion = await getFFmpegVersion();
122
+ if (existingVersion) {
123
+ console.log(`FFmpeg ${existingVersion} is already installed, skipping installation.`);
124
+ return;
125
+ }
126
+
127
+ // Also check if the formula is installed via Homebrew
128
+ // (FFmpeg may be installed but not in PATH for some reason)
129
+ const formulaInstalled = await brew.isFormulaInstalled(HOMEBREW_FORMULA_NAME);
130
+ if (formulaInstalled) {
131
+ console.log('FFmpeg is already installed via Homebrew, skipping installation.');
132
+ console.log('');
133
+ console.log('NOTE: If FFmpeg commands are not working, check your PATH.');
134
+ console.log('Run: brew info ffmpeg');
135
+ return;
136
+ }
137
+
138
+ // Verify Homebrew is available
139
+ if (!brew.isInstalled()) {
140
+ throw new Error(
141
+ 'Homebrew is not installed. Please install Homebrew first using:\n' +
142
+ ' dev install homebrew\n' +
143
+ 'Then retry installing FFmpeg.'
144
+ );
145
+ }
146
+
147
+ console.log('Installing FFmpeg via Homebrew...');
148
+ console.log('This may take several minutes as FFmpeg has many dependencies...');
149
+
150
+ // Install FFmpeg formula (use --quiet flag for cleaner output)
151
+ const result = await shell.exec('brew install --quiet ffmpeg');
152
+
153
+ if (result.code !== 0) {
154
+ throw new Error(
155
+ `Failed to install FFmpeg via Homebrew.\n` +
156
+ `Output: ${result.stderr || result.stdout}\n\n` +
157
+ `Troubleshooting:\n` +
158
+ ` 1. Run 'brew update && brew cleanup' and retry\n` +
159
+ ` 2. Check for Homebrew issues: brew doctor\n` +
160
+ ` 3. Try manual installation: brew install ffmpeg`
161
+ );
162
+ }
163
+
164
+ // Verify installation succeeded
165
+ const version = await getFFmpegVersion();
166
+ if (!version) {
167
+ throw new Error(
168
+ 'Installation appeared to complete but FFmpeg was not found.\n\n' +
169
+ 'Please try:\n' +
170
+ ' 1. Restart your terminal session\n' +
171
+ ' 2. Run: ffmpeg -version'
172
+ );
173
+ }
174
+
175
+ console.log(`FFmpeg ${version} installed successfully.`);
176
+ console.log('');
177
+ console.log('Installed tools:');
178
+ console.log(' - ffmpeg: Video/audio transcoding tool');
179
+ console.log(' - ffprobe: Media file analyzer');
180
+ console.log(' - ffplay: Simple media player');
181
+ console.log('');
182
+ console.log('Verify installation with: ffmpeg -version');
183
+ }
184
+
185
+ /**
186
+ * Install FFmpeg on Ubuntu/Debian using APT.
187
+ *
188
+ * Prerequisites:
189
+ * - Ubuntu 20.04 LTS or later, or Debian 11 (Bullseye) or later
190
+ * - sudo privileges
191
+ * - At least 500 MB free disk space
192
+ *
193
+ * The version available in Ubuntu/Debian repositories may not be the latest,
194
+ * but is sufficient for most use cases. Ubuntu 24.04 LTS includes FFmpeg 6.1.1.
195
+ *
196
+ * @returns {Promise<void>}
197
+ * @throws {Error} If installation fails
198
+ */
199
+ async function install_ubuntu() {
200
+ console.log('Checking if FFmpeg is already installed...');
201
+
202
+ // Check if FFmpeg is already installed
203
+ const existingVersion = await getFFmpegVersion();
204
+ if (existingVersion) {
205
+ console.log(`FFmpeg ${existingVersion} is already installed, skipping installation.`);
206
+ return;
207
+ }
208
+
209
+ // Update package index before installing
210
+ console.log('Updating package index...');
211
+ const updateResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
212
+ if (updateResult.code !== 0) {
213
+ console.log('Warning: Could not update package index, continuing anyway...');
214
+ }
215
+
216
+ // Install FFmpeg via APT
217
+ console.log('Installing FFmpeg via APT...');
218
+ const installResult = await shell.exec(
219
+ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg'
220
+ );
221
+
222
+ if (installResult.code !== 0) {
223
+ throw new Error(
224
+ `Failed to install FFmpeg via APT.\n` +
225
+ `Output: ${installResult.stderr}\n\n` +
226
+ `Troubleshooting:\n` +
227
+ ` 1. Run 'sudo apt-get update' and retry\n` +
228
+ ` 2. Check available packages: apt-cache search ffmpeg\n` +
229
+ ` 3. Try manual installation: sudo apt-get install ffmpeg`
230
+ );
231
+ }
232
+
233
+ // Verify installation succeeded
234
+ const version = await getFFmpegVersion();
235
+ if (!version) {
236
+ throw new Error(
237
+ 'Installation appeared to complete but FFmpeg was not found.\n\n' +
238
+ 'Please try:\n' +
239
+ ' 1. Restart your terminal session\n' +
240
+ ' 2. Run: ffmpeg -version'
241
+ );
242
+ }
243
+
244
+ console.log(`FFmpeg ${version} installed successfully.`);
245
+ console.log('');
246
+ console.log('Installed tools:');
247
+ console.log(' - ffmpeg: Video/audio transcoding tool');
248
+ console.log(' - ffprobe: Media file analyzer');
249
+ console.log(' - ffplay: Simple media player');
250
+ console.log('');
251
+ console.log('NOTE: The repository version may not be the latest.');
252
+ console.log('For the latest version, consider using a PPA or static builds.');
253
+ }
254
+
255
+ /**
256
+ * Install FFmpeg on Raspberry Pi OS using APT.
257
+ *
258
+ * Prerequisites:
259
+ * - Raspberry Pi OS (Bookworm or Bullseye), 32-bit or 64-bit
260
+ * - Raspberry Pi 3 or later (earlier models have limited performance)
261
+ * - sudo privileges
262
+ * - At least 500 MB free disk space
263
+ *
264
+ * FFmpeg in the repositories is compiled for ARM architecture.
265
+ * Raspberry Pi OS Bookworm includes FFmpeg 5.1.6.
266
+ * Hardware acceleration features vary by Raspberry Pi model.
267
+ *
268
+ * @returns {Promise<void>}
269
+ * @throws {Error} If installation fails
270
+ */
271
+ async function install_raspbian() {
272
+ console.log('Checking if FFmpeg is already installed...');
273
+
274
+ // Check if FFmpeg is already installed
275
+ const existingVersion = await getFFmpegVersion();
276
+ if (existingVersion) {
277
+ console.log(`FFmpeg ${existingVersion} is already installed, skipping installation.`);
278
+ return;
279
+ }
280
+
281
+ // Update package index before installing
282
+ console.log('Updating package index...');
283
+ const updateResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
284
+ if (updateResult.code !== 0) {
285
+ console.log('Warning: Could not update package index, continuing anyway...');
286
+ }
287
+
288
+ // Install FFmpeg via APT
289
+ console.log('Installing FFmpeg via APT...');
290
+ const installResult = await shell.exec(
291
+ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg'
292
+ );
293
+
294
+ if (installResult.code !== 0) {
295
+ throw new Error(
296
+ `Failed to install FFmpeg via APT.\n` +
297
+ `Output: ${installResult.stderr}\n\n` +
298
+ `Troubleshooting:\n` +
299
+ ` 1. Run 'sudo apt-get update' and retry\n` +
300
+ ` 2. Check available packages: apt-cache search ffmpeg\n` +
301
+ ` 3. Try manual installation: sudo apt-get install ffmpeg`
302
+ );
303
+ }
304
+
305
+ // Verify installation succeeded
306
+ const version = await getFFmpegVersion();
307
+ if (!version) {
308
+ throw new Error(
309
+ 'Installation appeared to complete but FFmpeg was not found.\n\n' +
310
+ 'Please try:\n' +
311
+ ' 1. Restart your terminal session\n' +
312
+ ' 2. Run: ffmpeg -version'
313
+ );
314
+ }
315
+
316
+ console.log(`FFmpeg ${version} installed successfully.`);
317
+ console.log('');
318
+ console.log('Installed tools:');
319
+ console.log(' - ffmpeg: Video/audio transcoding tool');
320
+ console.log(' - ffprobe: Media file analyzer');
321
+ console.log(' - ffplay: Simple media player');
322
+ console.log('');
323
+ console.log('RASPBERRY PI NOTES:');
324
+ console.log(' - Check available hardware acceleration: ffmpeg -hwaccels');
325
+ console.log(' - Use V4L2 hardware encoder for H.264: -c:v h264_v4l2m2m');
326
+ console.log(' - Video encoding on Pi may be slow without hardware acceleration');
327
+ }
328
+
329
+ /**
330
+ * Install FFmpeg on Amazon Linux using static builds.
331
+ *
332
+ * Prerequisites:
333
+ * - Amazon Linux 2023 (AL2023) or Amazon Linux 2 (AL2)
334
+ * - sudo privileges
335
+ * - At least 500 MB free disk space
336
+ * - curl for downloading
337
+ *
338
+ * IMPORTANT: FFmpeg is not available in the standard Amazon Linux repositories.
339
+ * This function downloads static pre-built binaries from BtbN's FFmpeg Builds
340
+ * (https://github.com/BtbN/FFmpeg-Builds), which is the recommended approach.
341
+ *
342
+ * The static builds include all common codecs and do not require additional
343
+ * dependencies. Builds are updated daily from FFmpeg master branch.
344
+ *
345
+ * @returns {Promise<void>}
346
+ * @throws {Error} If installation fails
347
+ */
348
+ async function install_amazon_linux() {
349
+ console.log('Checking if FFmpeg is already installed...');
350
+
351
+ // Check if FFmpeg is already installed
352
+ const existingVersion = await getFFmpegVersion();
353
+ if (existingVersion) {
354
+ console.log(`FFmpeg ${existingVersion} is already installed, skipping installation.`);
355
+ return;
356
+ }
357
+
358
+ // Detect architecture to download the correct build
359
+ console.log('Detecting system architecture...');
360
+ const archResult = await shell.exec('uname -m');
361
+ const arch = archResult.stdout.trim();
362
+ console.log(`Architecture: ${arch}`);
363
+
364
+ // Determine download URL based on architecture
365
+ // x86_64 = Intel/AMD, aarch64 = ARM64 (Graviton)
366
+ let downloadUrl;
367
+ let extractDir;
368
+
369
+ if (arch === 'x86_64') {
370
+ downloadUrl = 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz';
371
+ extractDir = 'ffmpeg-master-latest-linux64-gpl';
372
+ } else if (arch === 'aarch64') {
373
+ downloadUrl = 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz';
374
+ extractDir = 'ffmpeg-master-latest-linuxarm64-gpl';
375
+ } else {
376
+ throw new Error(
377
+ `Unsupported architecture: ${arch}\n` +
378
+ `FFmpeg static builds are available for x86_64 and aarch64 architectures.`
379
+ );
380
+ }
381
+
382
+ // Ensure xz utilities are installed (required to extract .tar.xz files)
383
+ console.log('Ensuring xz utilities are installed...');
384
+ const xzCheckResult = await shell.exec('command -v xz');
385
+ if (xzCheckResult.code !== 0) {
386
+ console.log('Installing xz utilities...');
387
+ const xzInstallResult = await shell.exec('sudo dnf install -y xz || sudo yum install -y xz');
388
+ if (xzInstallResult.code !== 0) {
389
+ throw new Error(
390
+ `Failed to install xz utilities (required to extract FFmpeg).\n` +
391
+ `Output: ${xzInstallResult.stderr}\n\n` +
392
+ `Troubleshooting:\n` +
393
+ ` 1. Ensure you have sudo privileges\n` +
394
+ ` 2. Try manually: sudo dnf install -y xz`
395
+ );
396
+ }
397
+ }
398
+
399
+ // Ensure /opt directory exists
400
+ console.log('Preparing installation directory...');
401
+ const mkdirResult = await shell.exec('sudo mkdir -p /opt');
402
+ if (mkdirResult.code !== 0) {
403
+ throw new Error(`Failed to create /opt directory: ${mkdirResult.stderr}`);
404
+ }
405
+
406
+ // Download FFmpeg static build
407
+ console.log('Downloading FFmpeg static build from BtbN...');
408
+ console.log('This may take a few minutes depending on your connection...');
409
+ const downloadResult = await shell.exec(
410
+ `cd /tmp && curl -L -o ffmpeg.tar.xz "${downloadUrl}"`
411
+ );
412
+
413
+ if (downloadResult.code !== 0) {
414
+ throw new Error(
415
+ `Failed to download FFmpeg.\n` +
416
+ `Output: ${downloadResult.stderr}\n\n` +
417
+ `Troubleshooting:\n` +
418
+ ` 1. Check your internet connection\n` +
419
+ ` 2. Try downloading manually:\n` +
420
+ ` curl -L -o /tmp/ffmpeg.tar.xz "${downloadUrl}"`
421
+ );
422
+ }
423
+
424
+ // Extract the archive to /opt
425
+ console.log('Extracting FFmpeg to /opt...');
426
+ const extractResult = await shell.exec(
427
+ 'sudo tar -xf /tmp/ffmpeg.tar.xz -C /opt/'
428
+ );
429
+
430
+ if (extractResult.code !== 0) {
431
+ throw new Error(
432
+ `Failed to extract FFmpeg.\n` +
433
+ `Output: ${extractResult.stderr}\n\n` +
434
+ `Troubleshooting:\n` +
435
+ ` 1. Ensure you have sudo privileges\n` +
436
+ ` 2. Check if /opt has enough space\n` +
437
+ ` 3. Try manual extraction: sudo tar -xf /tmp/ffmpeg.tar.xz -C /opt/`
438
+ );
439
+ }
440
+
441
+ // Create symlinks in /usr/local/bin for easy access
442
+ console.log('Creating symlinks in /usr/local/bin...');
443
+ const symlinkCommands = [
444
+ `sudo ln -sf /opt/${extractDir}/bin/ffmpeg /usr/local/bin/ffmpeg`,
445
+ `sudo ln -sf /opt/${extractDir}/bin/ffprobe /usr/local/bin/ffprobe`
446
+ ];
447
+
448
+ for (const cmd of symlinkCommands) {
449
+ const result = await shell.exec(cmd);
450
+ if (result.code !== 0) {
451
+ console.log(`Warning: Could not create symlink: ${result.stderr}`);
452
+ }
453
+ }
454
+
455
+ // Clean up downloaded archive
456
+ console.log('Cleaning up temporary files...');
457
+ await shell.exec('rm -f /tmp/ffmpeg.tar.xz');
458
+
459
+ // Verify installation succeeded
460
+ const version = await getFFmpegVersion();
461
+ if (!version) {
462
+ throw new Error(
463
+ 'Installation appeared to complete but FFmpeg was not found.\n\n' +
464
+ 'Please try:\n' +
465
+ ' 1. Verify /usr/local/bin is in your PATH:\n' +
466
+ ` echo $PATH | grep -q '/usr/local/bin' && echo "OK" || echo "Missing"\n` +
467
+ ' 2. Add to PATH if missing:\n' +
468
+ ' echo \'export PATH="/usr/local/bin:$PATH"\' >> ~/.bashrc && source ~/.bashrc\n' +
469
+ ' 3. Run: ffmpeg -version'
470
+ );
471
+ }
472
+
473
+ console.log(`FFmpeg ${version} installed successfully.`);
474
+ console.log('');
475
+ console.log(`Installation location: /opt/${extractDir}/`);
476
+ console.log('Symlinks created in: /usr/local/bin/');
477
+ console.log('');
478
+ console.log('Installed tools:');
479
+ console.log(' - ffmpeg: Video/audio transcoding tool');
480
+ console.log(' - ffprobe: Media file analyzer');
481
+ console.log('');
482
+ console.log('NOTE: These static builds are updated daily from FFmpeg master branch.');
483
+ console.log('To upgrade, simply re-run this installer.');
484
+ }
485
+
486
+ /**
487
+ * Install FFmpeg on Windows using Chocolatey.
488
+ *
489
+ * Prerequisites:
490
+ * - Windows 10 or later (64-bit)
491
+ * - Administrator PowerShell or Command Prompt
492
+ * - Chocolatey package manager installed
493
+ *
494
+ * Chocolatey installs the "essentials" build which includes commonly-used
495
+ * codecs (x264, x265, VP8/VP9, Opus, AAC). The essentials build is compatible
496
+ * with Windows 7 and later.
497
+ *
498
+ * @returns {Promise<void>}
499
+ * @throws {Error} If Chocolatey is not installed or installation fails
500
+ */
501
+ async function install_windows() {
502
+ console.log('Checking if FFmpeg is already installed...');
503
+
504
+ // Check if FFmpeg is already installed
505
+ const existingVersion = await getFFmpegVersion();
506
+ if (existingVersion) {
507
+ console.log(`FFmpeg ${existingVersion} is already installed, skipping installation.`);
508
+ return;
509
+ }
510
+
511
+ // Check if FFmpeg is installed via Chocolatey
512
+ const packageInstalled = await choco.isPackageInstalled(CHOCO_PACKAGE_NAME);
513
+ if (packageInstalled) {
514
+ console.log('FFmpeg is already installed via Chocolatey, skipping installation.');
515
+ console.log('');
516
+ console.log('NOTE: If FFmpeg commands are not working, open a new terminal window');
517
+ console.log('to refresh your PATH, or run: refreshenv');
518
+ return;
519
+ }
520
+
521
+ // Verify Chocolatey is available
522
+ if (!choco.isInstalled()) {
523
+ throw new Error(
524
+ 'Chocolatey is not installed. Please install Chocolatey first:\n\n' +
525
+ 'Run the following in an Administrator PowerShell:\n' +
526
+ ' Set-ExecutionPolicy Bypass -Scope Process -Force; ' +
527
+ '[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ' +
528
+ 'iex ((New-Object System.Net.WebClient).DownloadString(\'https://community.chocolatey.org/install.ps1\'))\n\n' +
529
+ 'Then retry installing FFmpeg.'
530
+ );
531
+ }
532
+
533
+ console.log('Installing FFmpeg via Chocolatey...');
534
+ console.log('This may take a few minutes...');
535
+
536
+ // Install FFmpeg using Chocolatey
537
+ const result = await choco.install(CHOCO_PACKAGE_NAME);
538
+
539
+ if (!result.success) {
540
+ throw new Error(
541
+ `Failed to install FFmpeg via Chocolatey.\n` +
542
+ `Output: ${result.output}\n\n` +
543
+ `Troubleshooting:\n` +
544
+ ` 1. Ensure you are running as Administrator\n` +
545
+ ` 2. Try manual installation: choco install ffmpeg -y\n` +
546
+ ` 3. Check Chocolatey logs for details`
547
+ );
548
+ }
549
+
550
+ console.log('FFmpeg installed successfully.');
551
+ console.log('');
552
+ console.log('IMPORTANT: Open a new terminal window to refresh your PATH.');
553
+ console.log('Alternatively, run: refreshenv');
554
+ console.log('');
555
+ console.log('Installed tools:');
556
+ console.log(' - ffmpeg: Video/audio transcoding tool');
557
+ console.log(' - ffprobe: Media file analyzer');
558
+ console.log(' - ffplay: Simple media player');
559
+ console.log('');
560
+ console.log('Verify installation with: ffmpeg -version');
561
+ console.log('');
562
+ console.log('NOTE: For the "full" build with additional codecs:');
563
+ console.log(' choco uninstall ffmpeg -y && choco install ffmpeg-full -y');
564
+ }
565
+
566
+ /**
567
+ * Install FFmpeg on Ubuntu running in WSL (Windows Subsystem for Linux).
568
+ *
569
+ * Prerequisites:
570
+ * - Windows 10 version 2004 or higher, or Windows 11
571
+ * - WSL 2 enabled with Ubuntu distribution installed
572
+ * - sudo privileges within WSL
573
+ *
574
+ * FFmpeg installed in Windows is not accessible from WSL, so this function
575
+ * installs FFmpeg separately within the WSL Ubuntu environment using APT.
576
+ * The installation process is identical to native Ubuntu.
577
+ *
578
+ * @returns {Promise<void>}
579
+ * @throws {Error} If installation fails
580
+ */
581
+ async function install_ubuntu_wsl() {
582
+ console.log('Detected Ubuntu running in WSL (Windows Subsystem for Linux).');
583
+ console.log('');
584
+ console.log('Installing FFmpeg within WSL environment...');
585
+ console.log('');
586
+
587
+ // Check if FFmpeg is already installed
588
+ const existingVersion = await getFFmpegVersion();
589
+ if (existingVersion) {
590
+ console.log(`FFmpeg ${existingVersion} is already installed, skipping installation.`);
591
+ return;
592
+ }
593
+
594
+ // Update package index before installing
595
+ console.log('Updating package index...');
596
+ const updateResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
597
+ if (updateResult.code !== 0) {
598
+ console.log('Warning: Could not update package index, continuing anyway...');
599
+ }
600
+
601
+ // Install FFmpeg via APT
602
+ console.log('Installing FFmpeg via APT...');
603
+ const installResult = await shell.exec(
604
+ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ffmpeg'
605
+ );
606
+
607
+ if (installResult.code !== 0) {
608
+ throw new Error(
609
+ `Failed to install FFmpeg via APT.\n` +
610
+ `Output: ${installResult.stderr}\n\n` +
611
+ `Troubleshooting:\n` +
612
+ ` 1. If you see DNS errors, try:\n` +
613
+ ` echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf\n` +
614
+ ` 2. Run 'sudo apt-get update' and retry\n` +
615
+ ` 3. Try manual installation: sudo apt-get install ffmpeg`
616
+ );
617
+ }
618
+
619
+ // Verify installation succeeded
620
+ const version = await getFFmpegVersion();
621
+ if (!version) {
622
+ throw new Error(
623
+ 'Installation appeared to complete but FFmpeg was not found.\n\n' +
624
+ 'Please try:\n' +
625
+ ' 1. Restart your WSL session\n' +
626
+ ' 2. Run: ffmpeg -version'
627
+ );
628
+ }
629
+
630
+ console.log(`FFmpeg ${version} installed successfully.`);
631
+ console.log('');
632
+ console.log('Installed tools:');
633
+ console.log(' - ffmpeg: Video/audio transcoding tool');
634
+ console.log(' - ffprobe: Media file analyzer');
635
+ console.log(' - ffplay: Simple media player (requires X server for display)');
636
+ console.log('');
637
+ console.log('WSL NOTES:');
638
+ console.log(' - Access Windows files through /mnt/c/, /mnt/d/, etc.');
639
+ console.log(' - Example: ffmpeg -i /mnt/c/Users/You/Videos/input.mp4 output.webm');
640
+ console.log(' - ffplay requires WSLg (Windows 11) or an X server (Windows 10)');
641
+ }
642
+
643
+ /**
644
+ * Install FFmpeg in Git Bash on Windows using portable static builds.
645
+ *
646
+ * Prerequisites:
647
+ * - Windows 10 or later (64-bit)
648
+ * - Git Bash installed (comes with Git for Windows)
649
+ * - Internet access to download static builds
650
+ * - unzip command available (included with Git Bash)
651
+ *
652
+ * Git Bash runs in a MinGW environment on Windows. This function downloads
653
+ * portable FFmpeg static builds from gyan.dev that require no installation.
654
+ * The binaries are placed in ~/bin which is added to PATH.
655
+ *
656
+ * @returns {Promise<void>}
657
+ * @throws {Error} If installation fails
658
+ */
659
+ async function install_gitbash() {
660
+ console.log('Detected Git Bash on Windows.');
661
+ console.log('');
662
+ console.log('Installing FFmpeg using portable static builds...');
663
+ console.log('');
664
+
665
+ // Check if FFmpeg is already available
666
+ const existingVersion = await getFFmpegVersion();
667
+ if (existingVersion) {
668
+ console.log(`FFmpeg ${existingVersion} is already installed, skipping installation.`);
669
+ return;
670
+ }
671
+
672
+ // Create ~/bin directory if it doesn't exist
673
+ console.log('Creating ~/bin directory...');
674
+ const mkdirResult = await shell.exec('mkdir -p ~/bin');
675
+ if (mkdirResult.code !== 0) {
676
+ throw new Error(`Failed to create ~/bin directory: ${mkdirResult.stderr}`);
677
+ }
678
+
679
+ // Download the static build from gyan.dev
680
+ console.log('Downloading FFmpeg static build from gyan.dev...');
681
+ console.log('This may take a few minutes depending on your connection...');
682
+ const downloadUrl = 'https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip';
683
+ const downloadResult = await shell.exec(
684
+ `cd /tmp && curl -L -o ffmpeg.zip "${downloadUrl}"`
685
+ );
686
+
687
+ if (downloadResult.code !== 0) {
688
+ throw new Error(
689
+ `Failed to download FFmpeg.\n` +
690
+ `Output: ${downloadResult.stderr}\n\n` +
691
+ `Troubleshooting:\n` +
692
+ ` 1. Check your internet connection\n` +
693
+ ` 2. If you see certificate errors, try:\n` +
694
+ ` curl -L -k -o /tmp/ffmpeg.zip "${downloadUrl}"\n` +
695
+ ` 3. Try downloading manually in a browser`
696
+ );
697
+ }
698
+
699
+ // Extract the binaries
700
+ console.log('Extracting FFmpeg binaries...');
701
+ const extractResult = await shell.exec(
702
+ 'cd /tmp && unzip -q ffmpeg.zip -d /tmp/ffmpeg-extract'
703
+ );
704
+
705
+ if (extractResult.code !== 0) {
706
+ throw new Error(
707
+ `Failed to extract FFmpeg.\n` +
708
+ `Output: ${extractResult.stderr}\n\n` +
709
+ `Troubleshooting:\n` +
710
+ ` 1. Ensure unzip is available: which unzip\n` +
711
+ ` 2. Try manual extraction:\n` +
712
+ ` unzip /tmp/ffmpeg.zip -d /tmp/ffmpeg-extract`
713
+ );
714
+ }
715
+
716
+ // Move the executables to ~/bin
717
+ console.log('Installing FFmpeg binaries to ~/bin...');
718
+ const moveResult = await shell.exec(
719
+ 'mv /tmp/ffmpeg-extract/ffmpeg-*/bin/*.exe ~/bin/'
720
+ );
721
+
722
+ if (moveResult.code !== 0) {
723
+ throw new Error(
724
+ `Failed to move FFmpeg binaries.\n` +
725
+ `Output: ${moveResult.stderr}`
726
+ );
727
+ }
728
+
729
+ // Make sure executables are executable (shouldn't be needed on Windows but just in case)
730
+ await shell.exec('chmod +x ~/bin/ffmpeg.exe ~/bin/ffprobe.exe ~/bin/ffplay.exe 2>/dev/null || true');
731
+
732
+ // Clean up temporary files
733
+ console.log('Cleaning up temporary files...');
734
+ await shell.exec('rm -rf /tmp/ffmpeg.zip /tmp/ffmpeg-extract');
735
+
736
+ // Check if ~/bin is in PATH and add it if needed
737
+ const pathCheckResult = await shell.exec('echo $PATH | grep -q "$HOME/bin"');
738
+ if (pathCheckResult.code !== 0) {
739
+ console.log('Adding ~/bin to PATH in ~/.bashrc...');
740
+ await shell.exec('echo \'export PATH="$HOME/bin:$PATH"\' >> ~/.bashrc');
741
+ console.log('');
742
+ console.log('IMPORTANT: Run "source ~/.bashrc" or restart Git Bash to update PATH.');
743
+ }
744
+
745
+ // Source bashrc and verify installation
746
+ // Note: We need to check with the full path since PATH may not be updated yet
747
+ const verifyResult = await shell.exec('~/bin/ffmpeg.exe -version');
748
+ if (verifyResult.code !== 0) {
749
+ throw new Error(
750
+ 'Installation appeared to complete but FFmpeg verification failed.\n\n' +
751
+ 'Please try:\n' +
752
+ ' 1. Restart Git Bash\n' +
753
+ ' 2. Run: ~/bin/ffmpeg.exe -version'
754
+ );
755
+ }
756
+
757
+ // Parse version from verification output
758
+ const versionMatch = verifyResult.stdout.match(/ffmpeg version\s+([^\s]+)/);
759
+ const version = versionMatch ? versionMatch[1] : 'unknown';
760
+
761
+ console.log(`FFmpeg ${version} installed successfully.`);
762
+ console.log('');
763
+ console.log('Installation location: ~/bin/');
764
+ console.log('');
765
+ console.log('Installed tools:');
766
+ console.log(' - ffmpeg.exe: Video/audio transcoding tool');
767
+ console.log(' - ffprobe.exe: Media file analyzer');
768
+ console.log(' - ffplay.exe: Simple media player');
769
+ console.log('');
770
+ console.log('GIT BASH NOTES:');
771
+ console.log(' - For Windows paths, use double slashes: //c/Users/...');
772
+ console.log(' - Or use MSYS_NO_PATHCONV=1 before commands');
773
+ console.log(' - Restart Git Bash or run: source ~/.bashrc');
774
+ }
775
+
776
+ /**
777
+ * Check if FFmpeg is currently installed on the system.
778
+ *
779
+ * This function checks for FFmpeg installation across all supported platforms:
780
+ * - macOS: Checks for FFmpeg via Homebrew formula or ffmpeg command
781
+ * - Windows: Checks for FFmpeg via Chocolatey or ffmpeg command
782
+ * - Linux/Git Bash: Checks if ffmpeg command exists in PATH
783
+ *
784
+ * @returns {Promise<boolean>} True if FFmpeg is installed, false otherwise
785
+ */
786
+ async function isInstalled() {
787
+ const platform = os.detect();
788
+
789
+ if (platform.type === 'macos') {
790
+ // Check if FFmpeg formula is installed via Homebrew
791
+ const formulaInstalled = await brew.isFormulaInstalled(HOMEBREW_FORMULA_NAME);
792
+ if (formulaInstalled) {
793
+ return true;
794
+ }
795
+ // Also check if ffmpeg command exists
796
+ return isFFmpegCommandAvailable();
797
+ }
798
+
799
+ if (platform.type === 'windows') {
800
+ // Check if FFmpeg package is installed via Chocolatey
801
+ const packageInstalled = await choco.isPackageInstalled(CHOCO_PACKAGE_NAME);
802
+ if (packageInstalled) {
803
+ return true;
804
+ }
805
+ // Also check if ffmpeg command exists
806
+ return isFFmpegCommandAvailable();
807
+ }
808
+
809
+ // Linux, WSL, and Git Bash: Check if ffmpeg command exists
810
+ return isFFmpegCommandAvailable();
811
+ }
812
+
813
+ /**
814
+ * Check if this installer is supported on the current platform.
815
+ * FFmpeg is supported on all major platforms.
816
+ * @returns {boolean} True if installation is supported on this platform
817
+ */
818
+ function isEligible() {
819
+ const platform = os.detect();
820
+ return ['macos', 'ubuntu', 'debian', 'wsl', 'raspbian', 'amazon_linux', 'rhel', 'fedora', 'windows', 'gitbash'].includes(platform.type);
821
+ }
822
+
823
+ /**
824
+ * Main installation entry point.
825
+ *
826
+ * Detects the current platform and runs the appropriate installer function.
827
+ * Handles platform-specific mappings to ensure all supported platforms
828
+ * have appropriate installation logic.
829
+ *
830
+ * Supported platforms:
831
+ * - macOS: FFmpeg via Homebrew
832
+ * - Ubuntu/Debian: FFmpeg via APT
833
+ * - Raspberry Pi OS: FFmpeg via APT
834
+ * - Amazon Linux/RHEL: FFmpeg via static builds
835
+ * - Windows: FFmpeg via Chocolatey
836
+ * - WSL (Ubuntu): FFmpeg via APT within WSL
837
+ * - Git Bash: FFmpeg portable builds
12
838
  *
13
839
  * @returns {Promise<void>}
14
840
  */
15
841
  async function install() {
16
842
  const platform = os.detect();
17
843
 
18
- switch (platform.type) {
19
- case 'macos':
20
- // TODO: Implement macOS installation
21
- break;
22
- case 'debian':
23
- // TODO: Implement Debian/Ubuntu installation
24
- break;
25
- case 'rhel':
26
- // TODO: Implement RHEL/Amazon Linux installation
27
- break;
28
- case 'windows-wsl':
29
- // TODO: Implement WSL installation
30
- break;
31
- case 'windows':
32
- // TODO: Implement Windows installation
33
- break;
34
- default:
35
- console.error(`Unsupported platform: ${platform.type}`);
36
- process.exit(1);
37
- }
38
- }
39
-
40
- module.exports = { install };
844
+ // Map platform types to their installer functions
845
+ // This mapping handles aliases (e.g., debian maps to ubuntu installer)
846
+ const installers = {
847
+ 'macos': install_macos,
848
+ 'ubuntu': install_ubuntu,
849
+ 'debian': install_ubuntu,
850
+ 'wsl': install_ubuntu_wsl,
851
+ 'raspbian': install_raspbian,
852
+ 'amazon_linux': install_amazon_linux,
853
+ 'rhel': install_amazon_linux,
854
+ 'fedora': install_amazon_linux,
855
+ 'windows': install_windows,
856
+ 'gitbash': install_gitbash
857
+ };
858
+
859
+ const installer = installers[platform.type];
860
+
861
+ if (!installer) {
862
+ console.log(`FFmpeg is not available for ${platform.type}.`);
863
+ return;
864
+ }
865
+
866
+ await installer();
867
+ }
868
+
869
+ // Export all functions for use as a module and for testing
870
+ module.exports = {
871
+ install,
872
+ isInstalled,
873
+ isEligible,
874
+ install_macos,
875
+ install_ubuntu,
876
+ install_ubuntu_wsl,
877
+ install_raspbian,
878
+ install_amazon_linux,
879
+ install_windows,
880
+ install_gitbash
881
+ };
41
882
 
883
+ // Allow direct execution: node ffmpeg.js
42
884
  if (require.main === module) {
43
- install();
885
+ install().catch(err => {
886
+ console.error(err.message);
887
+ process.exit(1);
888
+ });
44
889
  }