Open rucker opened 1 year ago
I almost don't know but think something like this will be better. Not sure it works in mpv script environment.
function find_existing_path(paths)
for _, path in ipairs(paths) do
if file_exists(path) then
return path
end
end
return nil
end
ffmpeg_path = "ffmpeg"
if ON_MAC then
ffmpeg_path = find_existing_path({"/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg"})
Or may be even
ffmpeg_path = find_existing_path({"ffmpeg", "/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg"})
@SemperPeritus I like the idea! I pushed a change that mostly does what you suggested but still handles Mac as a special case. It also looks for ffmpeg
at HOME/bin
since that's one suggested prefix in their compilation guide.
We could take that a step further and just use the ExecutableFinder
on all platforms but that would require some further refactoring. Right now it looks like ExecutableFinder:get_executable_path()
calls find_executable()
but its return value is only used in a truthy context: i.e. if something is returned, we know we can just invoke it by name later.
@marzzzello Do I have this right? Do you have a strong opinion?
If your mpv is already in PATH, this is pointless. Just launch the subprocess with mpv
/ffmpeg
, it will resolve.
If you didn't install via Homebrew, and are using an app bundle, this won't work.
You'll need to locate the currently mpv executable, and strip -bundle
to use the command line version. The app bundle can be located anywhere, it may not be in Applications.
https://github.com/po5/thumbfast/blob/ccec64d13883fdd509244bb1b19db4b5ac1dc402/thumbfast.lua#L261-L263
Note that launching cli mpv from within an app bundle results in an icon quickly appearing and disappearing in Dock. If this is undesirable (it most certainly is since this script spawns one process per thumbnail), then you have to make a symlink to it from outside the app bundle. Then there won't be a Dock icon. File I linked has logic for this, and for notifying the user of it.
Add manual lookup of binaries on macOS due to the fact that the user's
PATH
isn't exposed to GUI applications, considering the following scenarios:/usr/local/
) and Apple Silicon Macs (/opt/homebrew/
)