Skip to content

Instantly share code, notes, and snippets.

@guidocella
Last active April 24, 2025 08:33
Show Gist options
  • Save guidocella/5f05794d0a8400b2393fe7a9995ebb43 to your computer and use it in GitHub Desktop.
Save guidocella/5f05794d0a8400b2393fe7a9995ebb43 to your computer and use it in GitHub Desktop.
mpv script to bookmarks scenes in EDL playlists. Press Ctrl+e to mark the start of a scene, then press it a second time to mark the end and append the scene to bookmarks.edl.
local utils = require 'mp.utils'
local start
mp.add_key_binding('Ctrl+e', 'generate-edl', function ()
if start == nil then
start = mp.get_property_native('time-pos')
mp.osd_message('Saved start')
return
end
local directory, filename = utils.split_path(mp.get_property('path'))
if filename:find(',') then
filename = '%' .. #filename .. '%' .. filename
end
local bookmarks_exist = utils.file_info(directory .. '/bookmarks.edl')
local edl = io.open(directory .. '/bookmarks.edl', 'a')
if not bookmarks_exist then
edl:write('# mpv EDL v0\n')
end
edl:write(
filename .. ',' .. start .. ',' .. mp.get_property_native('time-pos') - start .. '\n'
)
edl:close()
start = nil
mp.osd_message('EDL updated')
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment