diff options
| author | kkard2 <[email protected]> | 2024-09-15 12:37:38 +0200 |
|---|---|---|
| committer | kkard2 <[email protected]> | 2024-09-15 12:37:38 +0200 |
| commit | 0d553b3b3ac73f793dd20ceaacda21cd109dc453 (patch) | |
| tree | 4bf9c4e42df80f504ac3557fa73d9b11570fbe71 /mpv/scripts | |
| parent | 28d5c2d102daa0c098631fc97e05f62554e14f85 (diff) | |
mpv cutting, idk if i want to do this with ab loop
Diffstat (limited to 'mpv/scripts')
| -rw-r--r-- | mpv/scripts/cat_cut.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mpv/scripts/cat_cut.lua b/mpv/scripts/cat_cut.lua new file mode 100644 index 0000000..13d4516 --- /dev/null +++ b/mpv/scripts/cat_cut.lua @@ -0,0 +1,43 @@ +local mp = require("mp") + +local cut_ab = function() + local a = mp.get_property_number("ab-loop-a") + local b = mp.get_property_number("ab-loop-b") + + if a == nil or b == nil then + mp.msg.error("ab loop not set") + return + end + + if a > b then + a, b = b, a + end + + --- @type string + local path = mp.get_property("path") + local i = 1 + local last_dot_idx = nil + while i <= #path do + if path:sub(i, i) == "." then + last_dot_idx = i + end + i = i + 1 + end + + if last_dot_idx == nil then + mp.msg.error("could not parse path: " .. path) + return + end + + local target_path = path:sub(1, last_dot_idx) .. a .. "-" .. b .. path:sub(last_dot_idx, nil) + + mp.commandv( + "run", "ffmpeg", + "-ss", a, + "-to", b, + "-i", path, + "-c", "copy", + target_path) +end + +mp.add_key_binding("c", cut_ab) |
