Skip to content

Commit 0bbd3d0

Browse files
committed
fix: add ffmpeg directory to PATH so node-rtsp-stream can spawn it
Fixes the "spawn ffmpeg ENOENT" error when launching from Finder on macOS. Problem: - Detection code finds ffmpeg at full path (e.g., /opt/homebrew/bin/ffmpeg) - But node-rtsp-stream doesn't support custom ffmpeg path option - When node-rtsp-stream spawns ffmpeg, it uses 'ffmpeg' which requires PATH - macOS GUI launches have minimal PATH without Homebrew directories Solution: - After finding ffmpeg, extract its directory and add to process.env.PATH - This makes ffmpeg available when node-rtsp-stream spawns it later - Works for both forward slashes (macOS/Linux) and backslashes (Windows) - Only modifies PATH when using explicit paths (not when ffmpeg already in PATH) Testing: - Launch from Finder: ffmpeg should now be found and spawn successfully - Launch from Terminal: continues to work as before - Cross-platform compatible with proper path separator handling
1 parent 2cfc722 commit 0bbd3d0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/services/RtspStreamService.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ export class RtspStreamService extends EventEmitter {
188188
version
189189
};
190190

191+
// Add ffmpeg directory to PATH so node-rtsp-stream can spawn it
192+
// This is critical for macOS GUI launches where PATH doesn't include Homebrew paths
193+
if (expandedPath !== 'ffmpeg') { // Only for explicit paths, not PATH-based
194+
const lastSlashIndex = expandedPath.lastIndexOf('/');
195+
const lastBackslashIndex = expandedPath.lastIndexOf('\\');
196+
const separatorIndex = Math.max(lastSlashIndex, lastBackslashIndex);
197+
198+
if (separatorIndex > 0) {
199+
const ffmpegDir = expandedPath.substring(0, separatorIndex);
200+
const pathSep = process.platform === 'win32' ? ';' : ':';
201+
202+
// Add to beginning of PATH so it takes precedence
203+
process.env.PATH = `${ffmpegDir}${pathSep}${process.env.PATH || ''}`;
204+
console.log(`[RtspStreamService] Added ${ffmpegDir} to PATH for node-rtsp-stream`);
205+
}
206+
}
207+
191208
console.log(`[RtspStreamService] ffmpeg found at ${expandedPath}: version ${version}`);
192209
return; // Success! Exit the function
193210
} catch (error) {

0 commit comments

Comments
 (0)