po5 / thumbfast

High-performance on-the-fly thumbnailer script for mpv
Mozilla Public License 2.0
760 stars 34 forks source link

Mac: Not works out of the box #48

Closed eko5624 closed 1 year ago

eko5624 commented 1 year ago

Workaround: ln -s /Applications/mpv.app/Contents/MacOS/mpv /usr/local/bin

Is there another way to fix this?

po5 commented 1 year ago

Does the script work fine after running that command?
I guess we just have to make more of an effort to find the actual path to the mpv executable.
This is also an issue on Windows for users that haven't added mpv to path.

hooke007 commented 1 year ago

This is also an issue on Windows for users that haven't added mpv to path.

No, as a windows portable mpv user, I can confirm that the script works well even though out of PATH.

po5 commented 1 year ago

It is, for those who don't have it in path and are launching mpv from outside its own directory.

eko: Does replacing "mpv" with "/Applications/mpv.app/Contents/MacOS/mpv" on this line also work?

https://github.com/po5/thumbfast/blob/14b6a1eb363d693f91caef55d1dcd4999b9f5bb3/thumbfast.lua#L293

Will try to add auto detection of the currently running executable path for a not-too-messy solution.

hooke007 commented 1 year ago

eko: Does replacing "mpv" with "/Applications/mpv.app/Contents/MacOS/mpv" on this line also work?

https://github.com/hooke007/MPV_lazy/discussions/186#discussioncomment-3875189 We actually tested before and it worked.

The only problem is the bundle app can be placed anywhere, we didn't find the solution to check it.

christoph-heinrich commented 1 year ago

The docs mention ~~osxbundle/ for Mac and ~~exe_dir/ for Windows.

hooke007 commented 1 year ago

see https://github.com/mpv-player/mpv/issues/10009 ~~exe_dir/ couldn't work for me.

Another info we noticed in that thread is the old thumbnailer(worker) doesn't have this issue(Mac).

po5 commented 1 year ago

Another info we noticed in that thread is the old thumbnailer(worker) doesn't have this issue.

At first glance this uses the exec_path variable which is user-defined, with a default value of

((os.getenv('PWD') or mp.get_property('working-directory')) .. ':' .. os.getenv('PATH'))

I've used functionally similar code before, but I don't know if that's enough to find the mpv path on Mac.

https://github.com/po5/audio_background/blob/85e7f3364aadc5ef4fd34cb091519003afd0f837/audio_background.lua#L35-L57

christoph-heinrich commented 1 year ago

We already have the PID. There has got to be a way of getting the path from the pid on every OS. On linux readlink /proc/<pid>/exe gives you the executable path, but no idea how to do it on mac or windows.

po5 commented 1 year ago

on my arch system:

$ ps -o comm= -p PIDHERE
mpv

$ which mpv
/usr/bin/mpv

Is that enough on Mac?

stackoverflow says this could work:

realpath /proc/PIDHERE/exe
eko5624 commented 1 year ago

ln -s /Applications/mpv.app/Contents/MacOS/mpv /usr/local/bin

Yes, after running this command it works well on my Mac.

po5 commented 1 year ago

Can you install thumbfast from the mac-test branch (https://github.com/po5/thumbfast/blob/mac-test/thumbfast.lua), and try the following:

Open a file in mpv through the terminal, hover on the timeline once.
Copy the PID displayed in terminal.
Open a second terminal, don't close mpv.
Run realpath /proc/PID_HERE/exe (replace PID_HERE)
Run ps -o comm= -p PID_HERE (replace PID_HERE)
Run which RESULT_OF_PREVIOUS_COMMAND (replace RESULT_OF_PREVIOUS_COMMAND with result of ps command above)

Post the output of the 3 commands you ran.
Hopefully that will get us the path to mpv, wherever it happens to be installed, on a Mac system.

eko5624 commented 1 year ago
/Applications/mpv.app/Contents/MacOS/mpv /Volumes/USB/Downloads/星际穿越.mkv 
Cannot find main.* for any supported scripting backend in: /Users/huangjiajia/.config/mpv/scripts
[thumbfast] script-opts/thumbfast.conf:8 unknown key 'tnpath', ignoring 
[thumbfast] script-opts/thumbfast.conf:29 unknown key 'min_duration', ignoring 
[thumbfast] script-opts/thumbfast.conf:31 unknown key 'precise', ignoring 
[thumbfast] script-opts/thumbfast.conf:33 unknown key 'frequency', ignoring 
[uosc] script-opts/uosc.conf:126 unknown key 'font_height_to_letter_width_ratio', ignoring 
[thumbfast] PID 6850 

Open second terminal:

huangjiajia@huangjiajiadeMacBook-Pro ~ % realpath /proc/6850/exe
realpath: /proc/6850/exe: No such file or directory
huangjiajia@huangjiajiadeMacBook-Pro ~ % ps -o comm= -p 6850
/Applications/mpv.app/Contents/MacOS/mpv
huangjiajia@huangjiajiadeMacBook-Pro ~ % which /Applications/mpv.app/Contents/MacOS/mpv
/Applications/mpv.app/Contents/MacOS/mpv
po5 commented 1 year ago

What about the ps+which commands (:

eko5624 commented 1 year ago

I reedited, please take a look.

po5 commented 1 year ago

Seems like ps -o comm= -p PID_HERE would do the trick! Thanks for helping out.

po5 commented 1 year ago

Does the script work out of the box on the latest commit?

hooke007 commented 1 year ago

Yes

eko5624 commented 1 year ago

Weird thing, when hovering on the timeline, there's one more mpv icon popped up on dock, like this:

QQ20221030-133833@2x
LampPrinter commented 1 year ago

Weird thing, when hovering on the timeline, there's one more mpv icon popped up on dock, like this: QQ20221030-133833@2x

Is there a solution to this? Whenever thumbnails get generated playing any video in MacOS, I get 2 more MPV icons in dock. Kinda irritating.

po5 commented 1 year ago

Another info we noticed in that thread is the old thumbnailer(worker) doesn't have this issue(Mac).

I've been able to set up a Mac VM and try this out. It doesn't even work out of the box, and the reason it doesn't generate extra icons is because it uses ffmpeg by default? I'll commit a solution that properly picks up on the symlink if the user made it.