Incremental Seek for MPV/MPV-Android

1 minute read

There are different steps, so let’s start w/ what is the same for each: the lua code. Note that the comment tell you how to edit the script so that incremental skip is more/less aggressive:

-- Create a lua file for this in `~/.config/mpv/scripts`
local seek_amount = 5 -- Skips 5s at a time
local seek_window = 2 -- how many seconds in between presses before button resets to normal 5s skips
local max_multiplier = 6  -- # of times before skips are capped (ie 5s * 6 = 30s max)
local last_seek_time = 0
local consecutive_seeks = 0

function smart_seek(back)
    local now = mp.get_time()
    
    if (now - last_seek_time) <= seek_window then
        consecutive_seeks = consecutive_seeks + 1
    else
        consecutive_seeks = 0
    end
    
    local multiplier = math.min(consecutive_seeks + 1, max_multiplier)
    local distance = seek_amount * multiplier
    mp.command("seek " .. (back and "-" or "") .. distance)
    
    last_seek_time = now
end

mp.add_key_binding(nil, "seek-smart", function() smart_seek(false) end)
mp.add_key_binding(nil, "seek-smart-back", function() smart_seek(true) end)

MPV (Desktop)

  1. Navigate to ~/.config/mpv/scripts
  2. Create a file called incrementalSeek.lua
  3. Paste the lua code above
  4. Go to back a directory to ~/.config/mpv and open the input.conf file
  5. Paste the following:
LEFT script-binding seek_smart_back
RIGHT script-binding seek_smart

MPV-Android

  1. (Inside File Explorer/adb) Navigate to android/media/ It is likely empty. Create a folder called is.xyz.mpv inside of it.
  2. (Inside File Explorer/adb) In the newly created folder, create a file called incrementalSeek.lua
  3. Paste the lua code below
  4. (Inside MPV Settings) Go to Advanced -> mpv.conf. On a new line, add: script=/sdcard/Android/media/is.xyz.mpv/incrementalSeek.lua
  5. (Inside MPV Settings) Select touch gestures and change double tap left + double tap right to custom
  6. (Inside MPV Settings) Go to Advanced -> input.conf and paste the following:
0x10003 script-binding seek_smart
0x10001 script-binding seek_smart_back