Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,6 @@ You may also, of course, just `cat` the files together yourself. See the [`cat_o

#### Footnotes

<sup>1</sup>You _may_ need to add `mpv[.exe]` to your `PATH` (and _will_ have to add `ffmpeg[.exe]` if you want faster generation).
<sup>1</sup>You _may_ need to add `mpv[.exe]` to your `PATH` (and _will_ have to add `ffmpeg[.exe]` if you want faster generation). Manual lookup of these binaries is attempted on macOS since GUI apps do not inherit user `PATH` on that OS.

<sup>2</sup>Tested on Linux (Arch), but it _should_ work on Windows/Mac and whatnot as well, if <sup>1</sup> has been taken care of.
<sup>2</sup>Tested on Linux (Arch, Ubuntu) and macOS, but it _should_ work on Windows and whatnot as well, if <sup>1</sup> has been taken care of.
9 changes: 9 additions & 0 deletions lib/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ function create_directories(path)
utils.subprocess(cmd)
end

function find_on_paths(name, paths)
for _, path in ipairs(paths) do
if file_exists(path .. name) then
return path .. name
end
end
return nil
end

-- Find an executable in PATH or CWD with the given name
function find_executable(name)
local delim = ON_WINDOWS and ";" or ":"
Expand Down
15 changes: 13 additions & 2 deletions src/thumbnailer_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ function create_thumbnail_mpv(file_path, timestamp, size, output_path, options)

local log_arg = "--log-file=" .. output_path .. ".log"

local mpv_path = ON_MAC and "/opt/homebrew/bin/mpv" or "mpv"
local mpv_path = nil
if ON_MAC then
local applications_path = "Applications/mpv.app/Contents/MacOS/"
mpv_path = find_on_paths("mpv", { applications_path, os.getenv("HOME") .. applications_path })
else mpv_path = "mpv"
end


local mpv_command = skip_nil({
mpv_path,
Expand Down Expand Up @@ -73,7 +79,12 @@ end
function create_thumbnail_ffmpeg(file_path, timestamp, size, output_path, options)
options = options or {}

local ffmpeg_path = ON_MAC and "/opt/homebrew/bin/ffmpeg" or "ffmpeg"
local ffmpeg_path = nil
if ON_MAC then
ffmpeg_path = find_on_paths("ffmpeg", { "/opt/homebrew/bin/", "/usr/local/bin/", os.getenv("HOME") .. "bin/" })
else ffmpeg_path = "mpv"
end


local ffmpeg_command = {
ffmpeg_path,
Expand Down