Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to locate mpv binary on macOS/Homebrew MPV installation (with workaround) #29

Open
rucker opened this issue Oct 9, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@rucker
Copy link

rucker commented Oct 9, 2022

Description of the bug
Thumbnailer job will fail to invoke mpv on macOS which causes the entire job to fail. Relevant log output is:

[   2.100][e][mpv_thumbnail_script_server] Thumbnailing command failed!
[   2.100][e][mpv_thumbnail_script_server] mpv process error: init
[   2.100][e][mpv_thumbnail_script_server] Process stdout:
[   2.100][e][mpv_thumbnail_script_server] Debug log: /tmp/mpv_thumbs_cache/test-file/000000.bgra.log
[   2.101][e][mpv_thumbnail_script_server] Output file missing! /tmp/mpv_thumbs_cache/test-file/000000.bgra

To Reproduce
Steps to reproduce the behavior:

  • On macOS, install MPV via Homebrew
  • Add Homebrew bin dir to $PATH
  • Set up thumbnail scripts and launch a video with autogenerate=true in your conf file.
  • Observe the error "Thumbnailing failed, check console for errors" in MPV
  • Check log file for output

Expected behavior
Thumbnailing job completes normally

Environment

  • OS: macOS Monterey 12.6
  • mpv version: 0.34.1
  • mpv_thumbnail_script version: 0.4.9

The Workaround
I noticed that the issue did not occur when I ran mpv on the CLI. Through some testing according to #16, I verified that the issue is that the mpv_command built by the script fails to invoke mpv. I worked around this by modifying the relevant line in the server to use the absolute path to mpv and everything works as expected. Either the homebrew bin path (which is a symlink to the application bundle, below) or the path to the binary in the app bundle worked just fine.

$ ls -l `which mpv`
lrwxr-xr-x 1 me admin 40 Oct  9 13:04 /opt/homebrew/bin/mpv -> /Applications/mpv.app/Contents/MacOS/mpv

As shown above, the Homebrew path /opt/homebrew/bin is on my user's $PATH. Adding the appropriate path to /etc/paths before starting MPV had no effect.

Recommendations
From a look through the code, it seems as though the server ExecutableFinder, which loads the user's environment to search for ffmpeg, could be used to find mpv as well.

@rucker rucker added the bug Something isn't working label Oct 9, 2022
@rucker rucker changed the title Pathing issues on macOS/Homebrew MPV installation (with workaround) Failure to locate mpv binary macOS/Homebrew MPV installation (with workaround) Oct 19, 2022
@rucker rucker changed the title Failure to locate mpv binary macOS/Homebrew MPV installation (with workaround) Failure to locate mpv binary on macOS/Homebrew MPV installation (with workaround) Oct 19, 2022
@marzzzello
Copy link
Owner

marzzzello commented Nov 4, 2022

How did you modify the PATH variable?
It looks like the CLI uses a different environment than the UI.
https://www.bounga.org/tips/2020/04/07/instructs-mac-os-gui-apps-about-path-environment-variable/
Have you tried setting the PATH in /etc/launchd?
EDIT: In the comments someone says that it no longer works :/

@rucker
Copy link
Author

rucker commented Nov 20, 2022

I am setting my PATH in my .bashrc. From what I've read, exposing user env vars to GUI applications on macOS is a nontrivial problem with a lot of potential solutions (depending on the version -- as you mentioned, launchd used to be one possibility but this is no longer the case).

At any rate, unless you want this thumbnailer script to go looking in known locations like Homebrew's bin dir that aren't on the default PATH (I understand if you don't), it seems to me that this is more of a system configuration issue.

Here are some possible solutions for anyone else facing this situation:

  1. Hard-code the path to mpv as shown in the OP above.
  2. Various possibilities listed here (warning, this is an old question with old answers so YMMV).

Unless there are other possibilities I'm not thinking of, you can probably close this issue.

@marzzzello
Copy link
Owner

So none of the possibilities in [2.] work? launchctl setenv PATH $PATH looked promising.
I could also add an option for setting the path to mpv.

@SemperPeritus
Copy link

The same problem. My workaround here: TheAMM#61

@rucker
Copy link
Author

rucker commented Feb 26, 2023

So none of the possibilities in [2.] work? launchctl setenv PATH $PATH looked promising. I could also add an option for setting the path to mpv.

I haven't tried everything in that SO thread, but launchctl setenv PATH $PATH unfortunately did not do the trick. I verified that the path is correct via launchctl getenv PATH but it had no apparent effect -- launching MPV after setting this resulted in the thumbnailer job failing as before. I agree it looked promising though!

@rucker
Copy link
Author

rucker commented Apr 4, 2023

@marzzzello @SemperPeritus Please have a look at #39, which I think will resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants