{"id":13679553,"url":"https://github.com/marzzzello/mpv_thumbnail_script","last_synced_at":"2025-04-29T19:31:27.246Z","repository":{"id":43302031,"uuid":"300285929","full_name":"marzzzello/mpv_thumbnail_script","owner":"marzzzello","description":"A Lua script to show preview thumbnails in mpv's OSC seekbar, sans external dependencies (fork)","archived":false,"fork":true,"pushed_at":"2024-07-01T08:15:19.000Z","size":2881,"stargazers_count":277,"open_issues_count":26,"forks_count":20,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-11T22:35:30.575Z","etag":null,"topics":["mpv","thumbnail-generator","thumbnails"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"TheAMM/mpv_thumbnail_script","license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marzzzello.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["marzzzello"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-10-01T13:17:02.000Z","updated_at":"2024-11-07T19:45:28.000Z","dependencies_parsed_at":"2023-01-27T03:15:50.543Z","dependency_job_id":"ee4915c6-7fd7-48c1-9ae6-8c67c292b881","html_url":"https://github.com/marzzzello/mpv_thumbnail_script","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzzzello%2Fmpv_thumbnail_script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzzzello%2Fmpv_thumbnail_script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzzzello%2Fmpv_thumbnail_script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marzzzello%2Fmpv_thumbnail_script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marzzzello","download_url":"https://codeload.github.com/marzzzello/mpv_thumbnail_script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251569548,"owners_count":21610575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mpv","thumbnail-generator","thumbnails"],"created_at":"2024-08-02T13:01:06.846Z","updated_at":"2025-04-29T19:31:25.311Z","avatar_url":"https://github.com/marzzzello.png","language":"Lua","funding_links":["https://github.com/sponsors/marzzzello"],"categories":["Lua","On Screen Controller"],"sub_categories":[],"readme":"# `mpv_thumbnail_script.lua`\n\n[![](docs/mpv_thumbnail_script.gif \"Thumbnail preview for Sintel (2010) on mpv's seekbar\")](https://www.youtube.com/watch?v=a9cmt176WDI)\n[_Click the image (or here) to view a YouTube video of the script in action_](https://www.youtube.com/watch?v=a9cmt176WDI)\n\n_(You might also be interested in [`mpv_crop_script.lua`](https://github.com/TheAMM/mpv_crop_script))_\n\n---\n\n## What is it?\n\n`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[\u003csup\u003e1\u003c/sup\u003e](#footnotes), cross-platform-ly[\u003csup\u003e2\u003c/sup\u003e](#footnotes)!\n\nThe script supports all four built-in OSC layouts, [as seen in this Youtube video](https://www.youtube.com/watch?v=WsfWmO41p8A).\\\nThe script will also do multiple passes over the video, generating thumbnails with increasing frequency until the target is reached.\nThis allows you to preview the end of the file before every thumbnail has been generated.\n\n## How do I install it?\n\nGrab the `.lua` files from the [**releases page**](https://github.com/marzzzello/mpv_thumbnail_script/releases) and place them in mpv's `scripts` directory.\n\nFor example:\n\n- Linux/Unix/Mac: `~/.config/mpv/scripts/mpv_thumbnail_script_server.lua` \u0026 `~/.config/mpv/scripts/mpv_thumbnail_script_client_osc.lua`\n- Windows: `%APPDATA%\\mpv\\scripts\\mpv_thumbnail_script_server.lua` \u0026 `%APPDATA%\\mpv\\scripts\\mpv_thumbnail_script_client_osc.lua`\n\n(See the [Files section](https://mpv.io/manual/master/#files) in mpv's manual for more info.)\n\nYou should also read the [Configuration](#configuration) section.\n\nWhile the script doesn't need external dependencies and can work with mpv alone, it can also use FFmpeg for _slightly_ faster thumbnail generation; just make sure `ffmpeg[.exe]` is in your `PATH` and `prefer_mpv` is set to `no` in your configuration.\n\n**_However,_** FFmpeg does not support \"ordered chapters\" in MKVs (segment linking, ie. an `.mkv` references another `.mkv`), which can break the thumbnailing process. You have been warned.\n\nIn general, you should just use multiple worker scripts ([Configuration](#configuration)) instead of taking the FFmpeg-risk.\n\n## How do I use it?\n\nJust open a file and hover over the seekbar!\\\nAlthough by default, videos over an hour will require you to press the `T` (that's `shift+t`) keybind.\nYou may change this duration check in the configuration (`autogenerate_max_duration`).\n\n**Also of note:** the script does not manage the thumbnails in any way, you should clear the directory from time to time.\n\n## Configuration\n\n**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).\n\n**Multithreading:**\\\nThis script can use multiple concurrent thumbnailing jobs.\\\nSimply copy the `mpv_thumbnail_script_server.lua` once or twice (`mpv_thumbnail_script_server-1.lua`, `mpv_thumbnail_script_server-2.lua`) and the workers will automatically register themselves with the core.\\\nThis improves thumbnailing speed a bunch, but you will quickly max out your CPU - I recommend only having two or three copies of the script.\\\n(Why multiple copies of the same file? mpv gives each script their own thread - easy multithreading!)\n\nTo adjust the script's options, create a file called `mpv_thumbnail_script.conf` inside your mpv's `script-opts` directory.\n\nFor example:\n\n- Linux/Unix/Mac: `~/.config/mpv/script-opts/mpv_thumbnail_script.conf`\n- Windows: `%APPDATA%\\mpv\\script-opts\\mpv_thumbnail_script.conf`\n\n(See the [Files section](https://mpv.io/manual/master/#files) in mpv's manual for more info.)\n\nIn this file you may set the following options:\n\n```ini\n# The thumbnail cache directory.\n# On Windows this defaults to %TEMP%\\mpv_thumbs_cache,\n# and on other platforms to ${TEMP} or ${XDG_CACHE_HOME} or /tmp in the subfolder mpv_thumbs_cache\n# The directory will be created automatically, but must be writeable!\n# Use absolute paths, and take note that environment variables like %TEMP% are unsupported (despite the default)!\n# cache_directory=\n\n# Whether to generate thumbnails automatically on video load, without a keypress\n# Defaults to yes\nautogenerate=yes\n\n# Only automatically thumbnail videos shorter than this (in seconds)\n# You will have to press T (or your own keybind) to enable the thumbnail previews\n# Set to 0 to disable the check, ie. thumbnail videos no matter how long they are\n# Defaults to 3600 (one hour)\nautogenerate_max_duration=3600\n\n# Use mpv to generate thumbnail even if ffmpeg is found in PATH\n# ffmpeg is slightly faster than mpv but lacks support for ordered chapters in MKVs,\n# which can break the resulting thumbnails. You have been warned.\n# Defaults to yes (don't use ffmpeg)\nprefer_mpv=yes\n\n# Explicitly disable subtitles on the mpv sub-calls\n# mpv can and will by default render subtitles into the thumbnails.\n# If this is not what you wish, set mpv_no_sub to yes\n# Defaults to no\nmpv_no_sub=no\n\n# Enable to disable the built-in keybind (\"T\") to add your own, see after the block\n# Defaults to no\ndisable_keybinds=no\n\n# The maximum dimensions of the thumbnails, in pixels\n# Defaults to 200 and 200\nthumbnail_width=200\nthumbnail_height=200\n\n# The thumbnail count target\n# (This will result in a thumbnail every ~10 seconds for a 25 minute video)\n# Defaults to 150\nthumbnail_count=150\n\n# The above target count will be adjusted by the minimum and\n# maximum time difference between thumbnails.\n# The thumbnail_count will be used to calculate a target separation,\n# and min/max_delta will be used to constrict it.\n\n# In other words, thumbnails will be:\n# - at least min_delta seconds apart (limiting the amount)\n# - at most max_delta seconds apart (raising the amount if needed)\n# Defaults to 5 and 90, values are seconds\nmin_delta=5\nmax_delta=90\n# 120 seconds aka 2 minutes will add more thumbnails only when the video is over 5 hours long!\n\n# Parameter that mpv should use for hardware decoding\n# If properly configured can really improve thumbnail generation speed and cpu load\n# Default to no, see https://mpv.io/manual/master/#options-hwdec for the values\nmpv_hwdec=no\n\n# Parameter that mpv should use for seeking\n# yes extracts the exact frame\n# no extracts the closest keyframe, faster but less precise\n# Default to yes\nmpv_hr_seek=yes\n\n\n# Remote options\n\n\n# Below are overrides for remote urls (you generally want less thumbnails, because it's slow!)\n# Thumbnailing network paths will be done with mpv (leveraging youtube-dl)\n\n# Allow thumbnailing network paths (naive check for \"://\")\n# Defaults to no\nthumbnail_network=no\n\n# Same as autogenerate_max_duration but for remote videos\n# Defaults to 1200 (20 minutes)\nremote_autogenerate_max_duration=1200\n# Override thumbnail count, min/max delta, as above\nremote_thumbnail_count=60\nremote_min_delta=15\nremote_max_delta=120\n\n# Try to grab the raw stream and disable ytdl for the mpv subcalls\n# Much faster than passing the url to ytdl again, but may cause problems with some sites\n# Defaults to yes\nremote_direct_stream=yes\n\n# Enable storyboards (requires yt-dlp in PATH). Currently only supports YouTube and Twitch VoDs\n# Defaults to yes\nstoryboard_enable=yes\n# Max thumbnails for storyboards. It only skips processing some of the downloaded thumbnails and doesn't make it much faster\n# Defaults to 800\nstoryboard_max_thumbnail_count=800\n# Most storyboard thumbnails are 160x90. Enabling this allows upscaling them up to thumbnail_height\n# Defaults to no\nstoryboard_upscale=no\n\n\n# Display options\n\n\n# Move the thumbnail up or down\n# For example:\n#   topbar/bottombar: 24 (default)\n#   rest: 0\nvertical_offset=24\n\n# Adjust background padding\n# Examples:\n#   topbar:       0, 10, 10, 10\n#   bottombar    10,  0, 10, 10 (default)\n#   slimbox/box: 10, 10, 10, 10\npad_top=10\npad_bot=0\npad_left=10\npad_right=10\n\n# If enabled pad values are screen-pixels, else video-pixels.\n# Defaults to yes\npad_in_screenspace=yes\n\n# Calculate pad into the offset\n# Defaults to yes\noffset_by_pad=yes\n\n# Background color in BBGGRR\nbackground_color=000000\n\n# Alpha: 0 - fully opaque, 255 - transparent\n# Defaults to 80\nbackground_alpha=80\n\n# Keep thumbnail on the screen near left or right side\n# Defaults to yes\nconstrain_to_screen=yes\n\n# Do not display the thumbnailing progress\n# Defaults to no\nhide_progress=no\n```\n\n(see [`src/options.lua`](/src/options.lua) for all possible options)\n\nWith `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:\n\n```ini\nshift+alt+s script-binding generate-thumbnails\n```\n\n## Development\n\nIncluded 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!\n\nThe script requires Python 3, so install that. Nothing more, though. Call it with `concat_files.py cat_osc.json`.\n\nYou 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.\n\n#### Footnotes\n\n\u003csup\u003e1\u003c/sup\u003eYou _may_ need to add `mpv[.exe]` to your `PATH` (and _will_ have to add `ffmpeg[.exe]` if you want faster generation).\n\n\u003csup\u003e2\u003c/sup\u003eTested on Linux (Arch), but it _should_ work on Windows/Mac and whatnot as well, if \u003csup\u003e1\u003c/sup\u003e has been taken care of.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarzzzello%2Fmpv_thumbnail_script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarzzzello%2Fmpv_thumbnail_script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarzzzello%2Fmpv_thumbnail_script/lists"}