Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
samhippo authored Jul 24, 2021
1 parent e035d0f commit 159d08a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions clip-live-stream.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- trys to clip the last N seconds of a live stream/video using dump-cache
-- takes two parameters: the output folder and number of seconds
-- NOTE: it will create two files: .ts and .mkv. This is to ensure a compatible format is chosen.

local ov = mp.create_osd_overlay("ass-events")

function main(folder, seconds)
local start_time = mp.get_property_native("time-pos")-seconds
if start_time < 0 then start_time = 0 end
local end_time = mp.get_property("time-pos")
local filename = mp.get_property("media-title").." ".."["..math.floor(start_time).."-"..math.floor(end_time).."]"
local clean_filename = string.gsub(filename, "[/\\:%*%?\"|]", "_")
mp.commandv("dump-cache", start_time, end_time, folder..clean_filename..".ts")
mp.commandv("dump-cache", start_time, end_time, folder..clean_filename..".mkv")
ov.data = "{\\an4}{\\b1}{\\fs18}{\\1c&H00FFFF&}".."Saving Clip".."\n{\\an4}{\\b1}{\\fs18}{\\1c&H00FFFF&}"..folder..clean_filename
ov:update()
mp.add_timeout(5.0, function() ov:remove() end)
end

mp.register_script_message('clip-live-stream', main)

0 comments on commit 159d08a

Please sign in to comment.