Calling vlc.var.set(input, "time") in input callback
Posted: 02 Aug 2013 09:18
Hi,
I'm working on a script which can skip some sections I'm not interested in a video file, for example, skip the commercials or timeout section for a sports game. I think this can be done by implementing a VLC extension lua module.
The basic algorithm is like below, when the first time I watch the video, I skip these sections manually, and during the playback, I keep the start-end positions of each skipped sections in the script, and finally write down those data into a file when the playback ended. Next time when I play the same video file, the script will load the skipped sections, and whenever the playback time reach some skip section, the script will skip it by calling vlc.var.set(input, "time", nextPos).
However, I was blocked because when I call vlc.var.set(input, "time", nextPos) in the input callback function, VLC freeze and doesn't response to any user action, I can close the VLC main window, but the process is still alive so I need to use the task manager to kill the process. I try to put the code piece in another functions like activate() and input_changed(), and it works fine. I guess maybe do it in the callback function may hit some deadlock, but as long as this issue exist, there should be no other way to do my subject. Does anyone know how to work around this issue?
Below is the sample code to reproduce this issue, I work on a Windows 7 PC, VLC version 2.07,
-- Extension description
function descriptor()
return {
title = "Change Time Test" ;
version = "1.0" ;
author = "Kuway" ;
url = 'http://www.google.com';
shortdesc = "Change play position(time) in lua";
description = "Try to change position(time) of input in the input listener callback";
capabilities = { "input-listener" }
}
end
input = 0
function input_event_handler(var, old, new, data)
local CurrentPos = vlc.var.get(input, "time")
if CurrentPos % 10 < 1 then
vlc.var.set(input, "time", CurrentPos + 5)
end
end
function input_changed()
if input ~=0 then
-- Delete old callback
vlc.var.del_callback(input, "intf-event", input_event_handler, "Change time")
end
input = vlc.object.input()
if input ~= 0 then
vlc.var.add_callback(input, "intf-event", input_event_handler, "Change time")
end
end
function activate()
if vlc.object.input() then
input_changed()
end
end
function deactivate()
if input then
vlc.var.del_callback(input, "intf-event", input_event_handler, "Change time")
end
end
function meta_changed()
end
I'm working on a script which can skip some sections I'm not interested in a video file, for example, skip the commercials or timeout section for a sports game. I think this can be done by implementing a VLC extension lua module.
The basic algorithm is like below, when the first time I watch the video, I skip these sections manually, and during the playback, I keep the start-end positions of each skipped sections in the script, and finally write down those data into a file when the playback ended. Next time when I play the same video file, the script will load the skipped sections, and whenever the playback time reach some skip section, the script will skip it by calling vlc.var.set(input, "time", nextPos).
However, I was blocked because when I call vlc.var.set(input, "time", nextPos) in the input callback function, VLC freeze and doesn't response to any user action, I can close the VLC main window, but the process is still alive so I need to use the task manager to kill the process. I try to put the code piece in another functions like activate() and input_changed(), and it works fine. I guess maybe do it in the callback function may hit some deadlock, but as long as this issue exist, there should be no other way to do my subject. Does anyone know how to work around this issue?
Below is the sample code to reproduce this issue, I work on a Windows 7 PC, VLC version 2.07,
-- Extension description
function descriptor()
return {
title = "Change Time Test" ;
version = "1.0" ;
author = "Kuway" ;
url = 'http://www.google.com';
shortdesc = "Change play position(time) in lua";
description = "Try to change position(time) of input in the input listener callback";
capabilities = { "input-listener" }
}
end
input = 0
function input_event_handler(var, old, new, data)
local CurrentPos = vlc.var.get(input, "time")
if CurrentPos % 10 < 1 then
vlc.var.set(input, "time", CurrentPos + 5)
end
end
function input_changed()
if input ~=0 then
-- Delete old callback
vlc.var.del_callback(input, "intf-event", input_event_handler, "Change time")
end
input = vlc.object.input()
if input ~= 0 then
vlc.var.add_callback(input, "intf-event", input_event_handler, "Change time")
end
end
function activate()
if vlc.object.input() then
input_changed()
end
end
function deactivate()
if input then
vlc.var.del_callback(input, "intf-event", input_event_handler, "Change time")
end
end
function meta_changed()
end