Skip to content

Commit

Permalink
Update cut-video.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
samhippo authored Sep 3, 2020
1 parent 4fa3d7b commit 37cc464
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions cut-video.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local start_time_formated = nil
local start_time_seconds = nil
local end_time_seconds = nil
local end_time_formated = nil
local is_processing = false
local utils = require "mp.utils"
local ov = mp.create_osd_overlay("ass-events")

Expand Down Expand Up @@ -31,15 +32,48 @@ function fn_cut_finish(p1,p2)
table.insert(args,token)
end
table.insert(args,output_path)
utils.subprocess_detached({args = args, playback_only = false})
--utils.subprocess_detached({args = args, playback_only = false})


is_processing = true
ov.data = "\n{\\an4}{\\b1}{\\fs20}{\\1c&H00FFFF&}".."Processing..."
ov:update()

local r = mp.command_native({
name = "subprocess",
playback_only = false,
capture_stdout = true,
detach = false,
args = args,
})

print("result: " .. r.stdout)

start_time_formated = nil
start_time_seconds = nil
end_time_seconds = nil
end_time_formated = nil
is_processing = false
ov:remove()

end
end


function fn_cut_start()
start_time_seconds = 0
start_time_formated = "00:00:00"
mp.msg.info("START TIME: "..start_time_seconds)
showOnScreen()
end

function fn_cut_end()
end_time_seconds = mp.get_property_number("duration")
end_time_formated = mp.command_native({"expand-text","${duration}"})
mp.msg.info("END TIME: "..start_time_seconds)
showOnScreen()
end

function fn_cut_left()
start_time_seconds = mp.get_property_number("time-pos")
start_time_formated = mp.command_native({"expand-text","${time-pos}"})
Expand All @@ -57,10 +91,12 @@ end
function showOnScreen()
local st = (start_time_formated == nil and '' or start_time_formated)
local et = (end_time_formated == nil and '' or end_time_formated)
ov.data = "{\\an4}{\\b1}{\\fs14}{\\1c&H00FFFF&}".."End Time: "..et.."\n{\\an4}{\\b1}{\\fs14}{\\1c&H00FFFF&}".."Start Time: "..st
ov.data = "{\\an4}{\\b1}{\\fs20}{\\1c&H00FFFF&}".."Start: "..st.."\n{\\an4}{\\b1}{\\fs20}{\\1c&H00FFFF&}".."End: "..et
ov:update()
end

mp.register_script_message('cut-start', fn_cut_start)
mp.register_script_message('cut-end', fn_cut_end)
mp.register_script_message('cut-left', fn_cut_left)
mp.register_script_message('cut-right', fn_cut_right)
mp.register_script_message('cut-finish', fn_cut_finish)

1 comment on commit 37cc464

@KonoVitoDa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty to add some features to this: https://github.com/KonoVitoDa/mpv-scripts/blob/main/cut-video-mod.lua

Please sign in to comment.