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

Possible to put the thumbnails in the video's directory? #28

Open
scarlion1 opened this issue Sep 18, 2022 · 3 comments
Open

Possible to put the thumbnails in the video's directory? #28

scarlion1 opened this issue Sep 18, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@scarlion1
Copy link

Instead of having all the thumbnails saved into one directory, is it possible to save them in a ".thumbnails" subdirectory in the same directory the video is loaded from? Either with the config file or by editing the script code? I tried cache_directory=./.thumbnails but it puts the ".thumbnails" in my home directory.
Thanks

@scarlion1 scarlion1 added the enhancement New feature or request label Sep 18, 2022
@scarlion1
Copy link
Author

I've never programmed with mpv or lua before, but I feel like using mp.get_property("path") could be used. However when I try to use it the value is always "nil" I guess because the script is running before the video is loaded?

@scarlion1
Copy link
Author

Yay I figured out something! Just made some changes to function Thumbnailer:get_thumbnail_template() in mpv_thumbnail_script_client_osc.lua

Basically added local filedir, filename = utils.split_path(file_path) after the first line and added two join_paths() in place of the original.

Now if I set cache_directory=.thumbnails then the thumbnails get created in <the directory the video is in>/.thumbnails/<file_key>/

$ diff mpv_thumbnail_script_client_osc.lua mpv_thumbnail_script_client_osc.lua.orig 
919,920d918
<     local filedir, filename = utils.split_path(file_path)
< 
938,940c936
<     -- local thumbnail_directory = join_paths(self.cache_directory, file_key)
<     local thumbnail_directory_base = join_paths(filedir, self.cache_directory)
<     local thumbnail_directory = join_paths(thumbnail_directory_base, file_key)
---
>     local thumbnail_directory = join_paths(self.cache_directory, file_key)
$

@NicolaSmaniotto
Copy link
Collaborator

It would be nice to determine it automatically: if cache_directory isn't an absolute path, then consider it relative to the file being played.

On *nix, we can simply check for a / as first character, I don't know how it can be detected on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants