From 26e9907ff3a8fd48c238710b8a77c66c15ce8c77 Mon Sep 17 00:00:00 2001 From: familyfriendlymikey <15002903+familyfriendlymikey@users.noreply.github.com> Date: Fri, 17 Nov 2023 01:38:58 +0800 Subject: [PATCH] note about new latest homebrew versions/ffmpeg path --- README.md | 15 +++++++++++++++ main.lua | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index b40923f..f671a43 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,21 @@ All directly in the fantastic media player [mpv](https://mpv.io/installation/). Besides mpv, you must have `ffmpeg` in your PATH. +If you're launching mpv from Finder/Explorer, FFmpeg must be in your actual +system environment's PATH as opposed to your shell environment. This means +that changes to `~/.profile` or the like will not suffice. As such, on my +newest Macbook, after installing ffmpeg with homebrew I had to run the +following: + +``` +sudo ln -s /opt/homebrew/bin/ffmpeg /usr/local/bin/ffmpeg +``` + +## Tips + +To debug when launching from Finder/Explorer, use `` ` `` to display a terminal +with output. + ## Installation #### Linux/MacOS diff --git a/main.lua b/main.lua index 7db65aa..1997944 100644 --- a/main.lua +++ b/main.lua @@ -1,3 +1,7 @@ +-- NOTE TO FUTURE SELF: +-- To view debug logs when launching through Finder, +-- use the ` key in mpv instead of viewing ~/Library/Logs/mpv.log. + mp.msg.info("MPV-CUT LOADED") utils = require "mp.utils" @@ -20,6 +24,14 @@ local function table_to_str(o) end end +local result = mp.command_native({ name = "subprocess", args = {"ffmpeg"}, playback_only = false, capture_stdout = true, capture_stderr = true }) +mp.msg.info("Your PATH: " .. os.getenv('PATH')) +if result.status ~= 1 then + mp.osd_message("FFmpeg failed to run, please press ` for debug info", 5) + mp.msg.error("FFmpeg failed to run:\n" .. table_to_str(result)) + mp.msg.error("`which ffmpeg` output:\n" .. table_to_str(mp.command_native({ name = "subprocess", args = {"which", "ffmpeg"}, playback_only = false, capture_stdout = true, capture_stderr = true }))) +end + local function to_hms(seconds) local ms = math.floor((seconds - math.floor(seconds)) * 1000) local secs = math.floor(seconds)