SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -- save as ~/.mpv/lua/capture.lua |
| 1 | + | -- save as ~/.mpv/lua/capture.lua (new mpv versions) |
| 2 | -- or use as mpv --lua=/path/to/capture.lua | |
| 3 | -- usage: press «a» at start and at end of fragment | |
| 4 | -- will print commands for ffmpeg and mpv | |
| 5 | ||
| 6 | capture = {}
| |
| 7 | function capture.handler() | |
| 8 | local gp = mp.get_property | |
| 9 | local gpn = mp.get_property_number | |
| 10 | local sp = mp.set_property | |
| 11 | local c = capture | |
| 12 | local filesize = 6144 | |
| 13 | local maxfps = 35 | |
| 14 | if c.start == nil then | |
| 15 | c.start = gp("time-pos")
| |
| 16 | elseif c.finish == nil then | |
| 17 | c.finish = gp("time-pos")
| |
| 18 | local ffopts = "" | |
| 19 | - | local br = filesize * 8 / length - 100 |
| 19 | + | |
| 20 | local br = filesize * 8 / length - 128 | |
| 21 | if gpn("fps") > maxfps then
| |
| 22 | local fps = gpn("fps") / 2
| |
| 23 | end | |
| 24 | local h = gp("height")
| |
| 25 | local w = gp("width")
| |
| 26 | if w * h / br > 1000 then | |
| 27 | ffopts = ffopts .. string.format("-vf scale=%d:-1 ",
| |
| 28 | 0.0017) | |
| 29 | end | |
| 30 | ||
| 31 | print(string.format("ffmpeg -ss %f -i '%s' -t %f -b:v %dk %s -pass 1",
| |
| 32 | c.start, gp("path"), length, br,
| |
| 33 | fps and "-r " .. fps or "")) | |
| 34 | print(string.format("mpv --start %f '%s' --length %f --ovcopts b=%dk",
| |
| 35 | c.start, gp("path"), length, br))
| |
| 36 | c.start = nil | |
| 37 | c.finish = nil | |
| 38 | end | |
| 39 | end | |
| 40 | mp.add_key_binding("a", "capture", capture.handler) |