Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- capture = {}
- local gp
- if mp.get_property == nil then
- gp = mp.property_get
- else
- gp = mp.get_property
- end
- function capture.handler()
- local c = capture
- local osd_w, osd_h = mp.get_osd_size()
- local x, y = mp.get_mouse_pos()
- local rw = mp.get_property("width")
- local rh = mp.get_property("height")
- local ml = mp.get_property("osd-dimensions/ml")
- local mt = mp.get_property("osd-dimensions/mt")
- x = ( x - ml ) * rw / ( osd_w - 2 * ml )
- y = ( y - mt ) * rh / ( osd_h - 2 * mt )
- if c.trig then
- mp.commandv("show-text", string.format("coord 2 x=%d ; y=%d" , x, y))
- local f = assert(io.open("/tmp/webm_crop2", "w"))
- f:write(string.format("%d:%d", x, y))
- f:close()
- c.trig = nil
- else
- mp.commandv("show-text", string.format("coord 1 x=%d ; y=%d" , x, y))
- local f = assert(io.open("/tmp/webm_crop1", "w"))
- f:write(string.format("%d:%d", x, y))
- f:close()
- c.trig = 1
- end
- end
- mp.add_forced_key_binding("F9", capture.handler)
- if bindings_enabled then toggle_bindings(true, true) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement