mirror of
https://github.com/Phantop/dotfiles
synced 2024-12-05 04:55:18 +00:00
mpv: add scripts for cutting and cropping
This commit is contained in:
parent
78d08221dd
commit
47f0997098
|
@ -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
|
||||
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/autodeint.lua ~/.config/mpv/scripts
|
||||
|
||||
|
|
39
mpv/scripts/cut.lua
Normal file
39
mpv/scripts/cut.lua
Normal 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)
|
Loading…
Reference in a new issue