-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit (full features, readme+license)
Creates thumbnails iteratively now, in multiple passes. This way the end of the file can be previewed quickly, without having to wait for all the thumbs from start to end to be generated. Also lots of other stuff. Should be robust, lest users prove me wrong.
Showing
12 changed files
with
1,105 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# `mpv_thumbnail_script.lua` | ||
|
||
[![](docs/mpv_thumbnail_script.jpg "Thumbnail preview for Sintel (2010) on mpv's seekbar")](https://www.youtube.com/watch?v=a9cmt176WDI) | ||
[*Click the image or here to see the script in action*](https://www.youtube.com/watch?v=a9cmt176WDI) | ||
|
||
---- | ||
|
||
## What is it? | ||
|
||
`mpv_thumbnail_script.lua` is a script/replacement OSC for [mpv](https://github.com/mpv-player/mpv) to display preview thumbnails when hovering over the seekbar, without any external dependencies[<sup>1</sup>](#footnotes), cross-platform-ly[<sup>2</sup>](#footnotes)! | ||
|
||
The script supports all four built-in OSC layouts, [as seen in this Youtube video](https://www.youtube.com/watch?v=WsfWmO41p8A). | ||
The script will also do multiple passes over the video, generating thumbnails with increasing frequency until the target is reached. | ||
This allows you to preview the end of the file before every thumbnail has been generated. | ||
|
||
## How do I install it? | ||
|
||
Grab both the `mpv_thumbnail_script_server.lua` and `mpv_thumbnail_script_client_osc.lua` from the [releases page](https://github.com/TheAMM/mpv_thumbnail_script/releases) (or [see below](#development) how to "build" (concatenate) it yourself) and place them both to your mpv's `scripts` directory. (**Note!** Also see Configuration below) | ||
|
||
For example: | ||
* Linux/Unix/Mac: `~/.config/mpv/scripts/mpv_thumbnail_script_server.lua` & `~/.config/mpv/scripts/mpv_thumbnail_script_client_osc.lua` | ||
* Windows: `%APPDATA%\Roaming\mpv\scripts\mpv_thumbnail_script_server.lua` & `%APPDATA%\Roaming\mpv\scripts\mpv_thumbnail_script_client_osc.lua` | ||
|
||
See the [Files section](https://mpv.io/manual/master/#files) in mpv's manual for more info. | ||
|
||
The script can also use FFmpeg for faster thumbnail generation, which is highly recommended. | ||
Just make sure `ffmpeg[.exe]` is in your `PATH`. | ||
|
||
## How do I use it? | ||
|
||
Just open a file and hover over the seekbar! | ||
Although by default, videos over an hour will require you to press the `T` (that's `shift+t`) keybind. | ||
You may change this duration check in the configuration (`autogenerate_max_duration`). | ||
|
||
**Also of note:** the script does not manage the thumbnails in any way, you should clear the directory from time to time. | ||
|
||
## Configuration | ||
|
||
**Note!** Because this script replaces the built-in OSC, you will have to set `osc=no` in your mpv's [main config file](https://mpv.io/manual/master/#files). | ||
|
||
Create a file called `mpv_thumbnail_script.conf` inside your mpv's `lua-settings` directory to adjust the script's options. | ||
|
||
For example: | ||
* Linux/Unix/Mac: `~/.config/mpv/lua-settings/mpv_thumbnail_script.conf` | ||
* Windows: `%APPDATA%\Roaming\mpv\lua-settings\mpv_thumbnail_script.conf` | ||
|
||
See the [Files section](https://mpv.io/manual/master/#files) in mpv's manual for more info. | ||
|
||
In this file you may set the following options: | ||
```ini | ||
# The thumbnail cache directory. | ||
# On Windows this defaults to %TEMP%\mpv_thumbs_cache, | ||
# and on other platforms to /tmp/mpv_thumbs_cache. | ||
# The directory will be created automatically, but must be writeable! | ||
cache_directory=/tmp/my_mpv_thumbnails | ||
|
||
# Whether to generate thumbnails automatically on video load, without a keypress | ||
# Defaults to yes | ||
autogenerate=[yes/no] | ||
|
||
# Only automatically thumbnail videos shorter than this (in seconds) | ||
# You will have to press T (or your own keybind) to enable the thumbnail previews | ||
# Set to 0 to disable the check, ie. thumbnail videos no matter how long they are | ||
# Defaults to 3600 (one hour) | ||
autogenerate_max_duration=3600 | ||
|
||
# Use mpv to generate thumbnail even if ffmpeg is found in PATH | ||
# It's better to use ffmpeg, but the choice is yours | ||
# Defaults to no | ||
prefer_mpv=[yes/no] | ||
|
||
# Enable to disable the built-in keybind ("T") to add your own, see after the block | ||
disable_keybinds=[yes/no] | ||
|
||
# The maximum dimensions of the thumbnails, in pixels | ||
# Defaults to 200 and 200 | ||
thumbnail_width=200 | ||
thumbnail_height=200 | ||
|
||
# The thumbnail count target | ||
# (This will result in a thumbnail every ~10 seconds for a 25 minute video) | ||
thumbnail_count=150 | ||
|
||
# The above target count will be adjusted by the minimum and | ||
# maximum time difference between thumbnails. | ||
# The thumbnail_count will be used to calculate a target separation, | ||
# and min/max_delta will be used to constrict it. | ||
|
||
# In other words, thumbnails will be: | ||
# - at least min_delta seconds apart (limiting the amount) | ||
# - at most max_delta seconds apart (raising the amount if needed) | ||
# Defaults to 5 and 90, values are seconds | ||
min_delta=5 | ||
max_delta=90 | ||
# 120 seconds aka 2 minutes will add more thumbnails only when the video is over 5 hours long! | ||
``` | ||
|
||
With `disable_keybind=yes`, you can add your own keybind to [`input.conf`](https://mpv.io/manual/master/#input-conf) with `script-binding generate-thumbnails`, for example: | ||
```ini | ||
shift+alt+s script-binding generate-thumbnails | ||
``` | ||
|
||
## Development | ||
|
||
Included in the repository is the `concat_files.py` tool I use for automatically concatenating files upon their change, and also mapping changes to the output file back to the source files. It's really handy on stack traces when mpv gives you a line and column on the output file - no need to hunt down the right place in the source files! | ||
|
||
The script requires Python 3, so install that. Nothing more, though. Call it with `concat_files.py cat_osc.json`. | ||
|
||
You may also, of course, just `cat` the files together yourself. See the [`cat_osc.json`](cat_osc.json)/[`cat_server.json`](cat_server.json) for the order. | ||
|
||
### Donation | ||
|
||
If you *really* get a kick out of this (weirdo), you can [paypal me](https://www.paypal.me/TheAMM) or send bitcoins to `1K9FH7J3YuC9EnQjjDZJtM4EFUudHQr52d`. Just having the option there, is all. | ||
|
||
#### 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>2</sup>Developed & tested on Windows and Linux (Ubuntu), but it *should* work on Mac and whatnot as well, if <sup>1</sup> has been taken care of. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
{ | ||
"output" : "mpv_thumbnail_script_client_osc.lua", | ||
"files" : [ | ||
"src/license_blurb.lua", | ||
"<version>", | ||
"lib/helpers.lua", | ||
"src/options.lua", | ||
"src/thumbnailer_shared.lua", | ||
"src/patched_osc.lua" | ||
], | ||
|
||
"version_file" : "version.txt", | ||
"version_template_file" : "src/version.tmpl.lua", | ||
|
||
"header_prefix" : "--[ ", | ||
"header_suffix" : " ]--" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
{ | ||
"output" : "mpv_thumbnail_script_server.lua", | ||
"files" : [ | ||
"src/license_blurb.lua", | ||
"<version>", | ||
"lib/helpers.lua", | ||
"src/options.lua", | ||
"src/thumbnailer_shared.lua", | ||
"src/thumbnailer_server.lua" | ||
], | ||
|
||
"version_file" : "version.txt", | ||
"version_template_file" : "src/version.tmpl.lua", | ||
|
||
"header_prefix" : "--[ ", | ||
"header_suffix" : " ]--" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--[[ | ||
Copyright (C) 2017 AMM | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
]]-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--[[ | ||
mpv_thumbnail_script.lua {version} - commit {commit_short} (branch {branch}) | ||
https://github.com/TheAMM/mpv_thumbnail_script | ||
Built on {utc_now:%Y-%m-%d %H:%M:%S} | ||
]]-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |