Last active
October 3, 2025 20:09
-
-
Save makoConstruct/a824f3dab8c5657d6ab98cabacce8f6e to your computer and use it in GitHub Desktop.
Convert any movie into an experience of pure aesthetics by cutting it up and playing it in a random order
This file contains hidden or 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
| --[[ | |
| Plays a movie in random order, jumping every 5 seconds or so to a random position. Convert any movie into a purely aesthetic experience. Potentially useful for creating ambience in the background of something, a party for instance, less distracting than just playing the movie normally, though still a bit distracting. | |
| how to use this: get mpv, put this script in its config/scripts dir | |
| invoke mpv with a command like this: | |
| mpv --script-opts=random-seek-enable=yes,random-seek-seed=393 video/dl/Legend.1985.DC.1080p.BluRay.x265-RBG.mp4 | |
| the options include | |
| random-seek-enable: must be set yes for the extension to work | |
| random-seek-interval: how long each random jump is in seconds (default 5) | |
| random-seek-interval-plus: adds random variation on each pause length, and this says how long it is (default 0) | |
| random-seek-seed: the randomization order will always be the same usually, this lets you set a different random-seed that changes the order from the usual one. It can be anything, I think. I've only tested it with numbers. | |
| random-seek-prefer-keyframes: if set yes, it will only jump to keyframes. This makes it feel less chaotic, I ended up not liking that, so it defaults to false | |
| ]] | |
| local opts = { | |
| plus = tonumber(mp.get_opt("random-seek-interval-plus")) or 0, | |
| seed = mp.get_opt("random-seek-seed"), | |
| prefer_keyframes = mp.get_opt("random-seek-prefer-keyframes") or false, | |
| interval = tonumber(mp.get_opt("random-seek-interval")) or 5, | |
| } | |
| local function random_seek() | |
| local duration = mp.get_property_number("duration") | |
| if duration then | |
| local random_pos = math.random() * (duration - (opts.interval + opts.plus) - 0.001) -- to make sure it never reaches the very end and stops playing | |
| if opts.prefer_keyframes then | |
| mp.commandv("seek", random_pos, "absolute", "keyframes") | |
| else | |
| mp.commandv("seek", random_pos, "absolute") | |
| end | |
| end | |
| end | |
| local function setup_timer() | |
| local enabled = mp.get_opt("random-seek-enable") | |
| mp.msg.info(enabled) | |
| if enabled == "yes" then | |
| mp.msg.info("running random-seek extension") | |
| if opts.seed then | |
| math.randomseed(opts.seed) | |
| end | |
| function running() | |
| random_seek() | |
| mp.add_timeout(opts.interval + math.random()*opts.plus, running) | |
| end | |
| running() | |
| else | |
| mp.msg.info("not running random-seek extension") | |
| end | |
| end | |
| mp.register_event("file-loaded", setup_timer) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
prior art https://github.com/AN3223/dotfiles/blob/master/.config/mpv/lats.lua
seems to allow looping over multiple files, allows pausing, always goes to keyframes I think, doesn't have a "enable" option (recommends not permanently installing it).