Page 1 of 1
Possible to jump forward based on X subtitle keywords?
Posted: 13 Jul 2013 00:26
by evilperro
This would be used to skip intros for those that watch series subbed and which have a song playing as intro. Star Trek Enterprise for example begins its intro (not directly, usually the episode begins right in the middle of things/with a recap) with "It's been a long road getting from here to there"
I've been searching the forum for intro skippers but haven't seen this particular approach posted yet.
Can this be done with lua? Or with a plugin?
If "X sentence" then jump "user customized time".
Don't know if it's possible, but the lua/plugin could directly monitor the subtitle text being played in vlc. Or it could recurse the .srt/.sub/.whatever, look for X sentence and check the corresponding timestamp. Then perform jump when VLC is at that timestamp.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 13 Jul 2013 15:26
by Jean-Baptiste Kempf
Could be done with lua, I think, but not 100% sure.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 15 Jul 2013 14:19
by mederi
Yes, it is possible to make an extension for this. You just need to read the subtitle file and parse data in function input_changed() or function meta_changed() when opening a film and use vlc.var.add_callback(input, "intf-event", input_events_handler, "Hello"). Then wait for the right moment in function input_events_handler(var, old, new, data) to jump 80 seconds ahead in time. Check
Subtitler (lite) for reading and parsing SRT subtitles,
Previous frame or
Sampler for jumping in time.
I was using my old
gamepad with an usb extension cable when I was watching the same series. You know, 2 metres from my bed to my computer is too far
My gamepad has a simple utility called "Profile" to assign chosen keyboard keys to gamepad buttons. Then set 77 seconds in VLC preferences for one of jumps with appropriate hotkey.
It is also possible to make a very simple extension to define one hotkey and a desired time jump, or even better use Hotkeys interface script, that can be started automatically with VLC.
Or you can use some PC remote control, wireless mouse or keyboard, or use extension cable for wired ones.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 15 Jul 2013 22:47
by evilperro
So it can be done, great. Now I just need to find someone willing to do the programming, zero programming skills here.
As you mentioned, right now I have customized VLC:s native jump and bound it to keyboard but it'd be very neat indeed to have the process automated.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 02 Aug 2013 08:42
by kuway
I just worked on a similar subject but I was blocked by some issue, when I call vlc.var.set(input, "time", someTimeValue) inside the callback function (the input_event_handler), the player freeze and won't response to any user action. I guess it may hit some deadlock.I'll create another post to discuss this issue.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 03 Aug 2013 15:01
by evilperro
Great!
Another question - I don't expect this to happen, so more of a question whether it's even possible or not in an extension/plugin to vlc (doubt it):
pixel recognition of intro sequence prompts skip.
audio recognition of intro music/song prompts skip.
I know bot-program to MMORPG:s works with pixel recognition, so perhaps it could be done by a similar separate program to VLC which then sends VLC's hotkey for forward jump, which the user can customize in VLC prefrences.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 05 Aug 2013 12:16
by mederi
If you can use Subtitler (lite) to play SRT subtitles, then edit the script:
* find line 134> if actual_time>=v[1] and actual_time<=v[2] then
* insert next new lines>
Code: Select all
if string.match(v[3], "It's been a long road")~=nil then
local duration = vlc.var.get(input,"length")
vlc.var.set(input,"position", (v[1]+80) / duration)
break
end
Re: Possible to jump forward based on X subtitle keywords?
Posted: 05 Aug 2013 16:50
by evilperro
Can't get it to work.
Installed subtitler lite succesfully, .srt text is showing both in it's separate window and on vlc (32bit) 2.0.7 (and vlc:s native core is displaying it as well). However nothing happens when video reaches keyword sentence. I have restarted vlc.
here's how my code looks, I don't have STE anymore so I'm trying it out on the office (S05E13 @ 00:35):
Code: Select all
if subtitle==nil then
for i,v in pairs(subtitles) do
if actual_time>=v[1] and actual_time<=v[2] then
if string.match(v[3], "People learn in lots of different")~=nil then
local duration = vlc.var.get(input,"length")
vlc.var.set(input,"position", (v[1]+80) / duration)
break
end
--vlc.msg.info(actual_time.." << subtitle on")
subtitle=v
dlg:set_title(i.."/"..#subtitles.." Subtitler (lite)")
dlg:update()
edit: Marvellous! It works now! The problem was a line break in the .srt file
"People learn
in lots of different ways,"
does not work. if pasted exactly as that into subtitler lite it in fact does not appear to load into vlc at all; no option under view menu. If written out on one line the jump is not made, as said.
However another sentence that does not have line break in .srt file works if used as keyword
.
How can I modify the code so that it would work on multiple keywords? If I watch different shows I don't want to have to edit the script every time I switch to another one.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 06 Aug 2013 21:08
by mederi
"\n" is the new line breaker, but probably it would be better to use just couple of words from one line only.
You can make multiple copies of the extension file in extensions directory (different filenames) and edit also a title (line34> title = "Subtitler (lite)",) in each copy. Then you just use the right extension for the right series
Re: Possible to jump forward based on X subtitle keywords?
Posted: 26 Aug 2013 02:55
by joeklow
Can anyone share thought, what resolution intf-event provides in Lua for detecting playback position, in milliseconds?
Re: Possible to jump forward based on X subtitle keywords?
Posted: 26 Aug 2013 21:40
by mederi
intf-event responds 4 or 5 times per second on my computer. I do not know whether it depends on a played format and a power of computer. Probably it does.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 03 Oct 2013 17:42
by roumieh2000
Did someone succeed in doing it..
Curious to know the result
I want to do a similar thing but in a different way by telling the player to jump from certain time to another automatically if possible.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 18 Oct 2013 02:28
by cuttingEdge
I wanted to post a similar topic but I'm new to the board and for the life of me can't find how to post a new thread.
My question is: Is there a way to search subtitles while the video is playing in order to jump to a certain word in the subtitle?
I'm studying at university and want to jump forward in the professor's lecture.
Any help appreciated.
Re: Possible to jump forward based on X subtitle keywords?
Posted: 18 Oct 2013 14:17
by evilperro
I wanted to post a similar topic but I'm new to the board and for the life of me can't find how to post a new thread.
My question is: Is there a way to search subtitles while the video is playing in order to jump to a certain word in the subtitle?
I'm studying at university and want to jump forward in the professor's lecture.
Any help appreciated.
The new topic button is directly under the sub-forums title name ie "scripting and lua".
As for your question; perhaps simply opening the subtitle file in a text editor such as notepad, holding "ctrl" and "f" key → serach for keyword which would lead you to the timestamp would be a satisfiable solution? Then you can easily go to that time in vlc.
If the subtitles are "burnt in" into the video there is no way to achieve what you are looking for.