1
0
Fork 0
mirror of https://github.com/Phantop/dotfiles synced 2024-11-21 14:22:45 +00:00

mpv: add scripts for cutting and cropping

This commit is contained in:
Phantop 2024-08-11 12:54:02 -04:00
parent 78d08221dd
commit 47f0997098
2 changed files with 40 additions and 1 deletions

View file

@ -40,7 +40,7 @@ w https://github.com/mrzool/bash-sensible/raw/master/sensible.bash -O ~/.bashrc
w https://github.com/savq/paq-nvim/raw/master/lua/paq.lua -P ~/.config/nvim/lua w https://github.com/savq/paq-nvim/raw/master/lua/paq.lua -P ~/.config/nvim/lua
nvim +PaqInstall +q nvim +PaqInstall +q
mkdir -p ~/.config/mpv/scripts w https://github.com/4ndrs/PureMPV/raw/main/main.js -P ~/.config/mpv/scripts
ln -s /usr/share/mpv/scripts/autocrop.lua ~/.config/mpv/scripts ln -s /usr/share/mpv/scripts/autocrop.lua ~/.config/mpv/scripts
ln -s /usr/share/mpv/scripts/autodeint.lua ~/.config/mpv/scripts ln -s /usr/share/mpv/scripts/autodeint.lua ~/.config/mpv/scripts

39
mpv/scripts/cut.lua Normal file
View file

@ -0,0 +1,39 @@
function clip(name, value)
if value ~= 'no' then
a = mp.get_property("ab-loop-a")
b = value
p = mp.get_property("path")
w = mp.get_property("working-directory")
c = 'cd \\"' .. w .. '\\" \\&\\& ffmpeg -i \\"' .. p .. '\\" -c copy -ss ' .. a .. ' -to ' .. b .. ' clip.mkv'
os.execute("echo -n " .. c .. " | xsel -b")
end
end
x1 = nil
y1 = nil
function mouse()
m = mp.get_property_native("mouse-pos")
x = m.x
y = m.y
if x1 then
dx = x - x1
dy = y - y1
s = ':'
c = dx .. s .. dy .. s .. x1 .. s .. y1
p = mp.get_property("path")
w = mp.get_property("working-directory")
f = 'cd \\"' .. w .. '\\" \\&\\& ffmpeg -i \\"' .. p .. '\\" -vf crop=' .. c .. ' clip.mkv'
os.execute("echo -n " .. f .. " | xsel -b")
mp.osd_message("Copied crop values to clipboard")
x1 = nil
else
x1 = x
y1 = y
mp.osd_message("Got first coords")
end
end
mp.observe_property("ab-loop-b", "string", clip)
mp.add_key_binding("n", "mouse", mouse)