diff --git a/bin/setup b/bin/setup index 73dd4dd..86e60f4 100755 --- a/bin/setup +++ b/bin/setup @@ -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 diff --git a/mpv/scripts/cut.lua b/mpv/scripts/cut.lua new file mode 100644 index 0000000..b6db22c --- /dev/null +++ b/mpv/scripts/cut.lua @@ -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)