Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- save as ~/.mpv/lua/capture.lua (new mpv versions)
- -- or use as mpv --lua=/path/to/capture.lua
- -- usage: press «a» at start and at end of fragment
- -- will print commands for ffmpeg and mpv
- capture = {}
- function capture.handler()
- local gp = mp.get_property
- local gpn = mp.get_property_number
- local sp = mp.set_property
- local c = capture
- local filesize = 6144
- local maxfps = 35
- if c.start == nil then
- c.start = gp("time-pos")
- elseif c.finish == nil then
- c.finish = gp("time-pos")
- local ffopts = ""
- local length = c.finish - c.start
- local br = filesize * 8 / length - 128
- if gpn("fps") > maxfps then
- local fps = gpn("fps") / 2
- end
- local h = gp("height")
- local w = gp("width")
- if w * h / br > 1000 then
- ffopts = ffopts .. string.format("-vf scale=%d:-1 ",
- 0.0017)
- end
- print(string.format("ffmpeg -ss %f -i '%s' -t %f -b:v %dk %s -pass 1",
- c.start, gp("path"), length, br,
- fps and "-r " .. fps or ""))
- print(string.format("mpv --start %f '%s' --length %f --ovcopts b=%dk",
- c.start, gp("path"), length, br))
- c.start = nil
- c.finish = nil
- end
- end
- mp.add_key_binding("a", "capture", capture.handler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement