For example, there is video video.mp4, in it I want to quickly mark some parts when viewing it, for example 00:01:50, 00:05:00, 00:10:34, etc. And i need it to be saved in a file:
video.txt:
Code: Select all
00:01:50
00:05:00
00:10:34
Code: Select all
00:01:50
00:05:00
00:10:34
Hi,
Maybe you can try this extension: https://addons.videolan.org/p/1154020/
time seems to be saved to:
userdatadir().."/moments_tracker.txt"
Code: Select all
function descriptor()
return {
title = "Moments Tracker",
version = "1.0",
author = "ARahman Rashed",
url = 'http://aur-tech.blogspot.com',
shortdesc = "Bookmark your moments",
description = "",
capabilities = {"menu", "input-listener", "meta-listener", "playing-listener"}
}
end
-------------- Global variables -------------
checkpoints = {}
moments = {}
-- holds checkpoints' metadata (date,time,etc..)
checkpoints_meta = {}
-- path to the file where checkpoints and moments are saved
destination = nil
media_name = nil
-----------------------------------------------
-- helper function to copy array elements by value
function shallow_copy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
function get_media_meta()
input = vlc.object.input()
media_name = vlc.input.item():name()
end
function display_error_box()
error_dialog = vlc.dialog("As if life isn't harsh enough")
error_dialog:add_label("Ummm..please open a media file before switching on the extension and restart VLC")
end
function activate()
vlc.msg.dbg(vlc.config.userdatadir())
if pcall(get_media_meta) then
get_media_meta()
destination = vlc.config.userdatadir().."/moments_tracker.txt"
load_checkpoints_moments()
createGUI()
display_moments()
else display_error_box()
end
end
function createGUI()
main_layout = vlc.dialog("Moments tracker")
main_layout:add_label("<hr>",1,6,5,1)
main_layout:add_label("<b>Track Checkpoints :</b>")
checkpoint_l = main_layout:add_label("",2,7)
display_checkpoint_data()
mark_position_b = main_layout:add_button(" Time! ", mark_position, 1,8,1,1)
end
function display_checkpoint_data()
if checkpoints_meta[media_name][1]~=nil then
checkpoint_l:set_text("")
checkpoint_l:set_text("<i>last checkpoint : "..checkpoints_meta[media_name][2].."</i>")
else checkpoint_l:set_text("<i>No checkpoints marked for this media</i>")
end
end
function save_checkpoints_moments(s)
file= io.open(destination,"w")
for i,j in pairs(s) do
file:write(checkpoints_meta[i][2],"\n")
end
file:flush()
file:close()
end
function load_checkpoints_moments()
local i=0
local temp_name = ""
temp_moments ={}
checkpoints_meta[media_name] = {}
file = io.open(destination,w)
if (file) then
for line in file:lines() do
if line ~= nil then
if i%2 == 0 then -- parse checkpoints
for k,v,ch1,ch2 in string.gmatch(line,"(%w.+)~(%w.+)~(%w.+)~(%w.+)") do
checkpoints[k] = v
temp_name = k
checkpoints_meta[k] = {}
checkpoints_meta[k][1] = ch1
checkpoints_meta[k][2] = ch2
end
elseif line~="nil" then -- if mod
itr = string.gmatch(line, '([^(*&)]+)')
for chunks in itr do
for a,b in string.gmatch(chunks,"(%w.+)~(%w.+)") do
vlc.msg.dbg("b is ",b)
temp_moments[a]=b
vlc.msg.dbg("here1")
end -- second inner parser
end
moments[temp_name] = shallow_copy(temp_moments)
temp_moments = {}
end
end
i = i+1
end
else
file = io.open(destination,"w")
file:write("")
file:close()
end
vlc.msg.dbg("created checkpoints_meta")
end
function mark_position()
checkpoints[media_name] = vlc.var.get(input,"position")
checkpoints_meta[media_name][1] = os.date("%d/%m/%Y")
checkpoints_meta[media_name][2] = format_time(vlc.var.get(input,"time"))
display_checkpoint_data()
save_checkpoints_moments(checkpoints)
end
function format_time(s)
local seconds = s/1000000
return string.format("%02d",seconds)
end
Code: Select all
5;46;75;156;300;479;633;
Code: Select all
5
46
75
156
300
479
633
Return to “General VLC media player Troubleshooting”
Users browsing this forum: No registered users and 21 guests