Possible to jump forward based on X subtitle keywords?

Discuss your Lua playlist, album art and interface scripts.
evilperro
New Cone
New Cone
Posts: 9
Joined: 10 Mar 2013 17:50

Possible to jump forward based on X subtitle keywords?

Postby evilperro » 13 Jul 2013 00:26

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.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37519
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Possible to jump forward based on X subtitle keywords?

Postby Jean-Baptiste Kempf » 13 Jul 2013 15:26

Could be done with lua, I think, but not 100% sure.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1948
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Possible to jump forward based on X subtitle keywords?

Postby mederi » 15 Jul 2013 14:19

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.

evilperro
New Cone
New Cone
Posts: 9
Joined: 10 Mar 2013 17:50

Re: Possible to jump forward based on X subtitle keywords?

Postby evilperro » 15 Jul 2013 22:47

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.

kuway
New Cone
New Cone
Posts: 2
Joined: 02 Aug 2013 08:17

Re: Possible to jump forward based on X subtitle keywords?

Postby kuway » 02 Aug 2013 08:42

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.

evilperro
New Cone
New Cone
Posts: 9
Joined: 10 Mar 2013 17:50

Re: Possible to jump forward based on X subtitle keywords?

Postby evilperro » 03 Aug 2013 15:01

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.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1948
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Possible to jump forward based on X subtitle keywords?

Postby mederi » 05 Aug 2013 12:16

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

evilperro
New Cone
New Cone
Posts: 9
Joined: 10 Mar 2013 17:50

Re: Possible to jump forward based on X subtitle keywords?

Postby evilperro » 05 Aug 2013 16:50

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.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1948
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Possible to jump forward based on X subtitle keywords?

Postby mederi » 06 Aug 2013 21:08

"\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 :)

joeklow
New Cone
New Cone
Posts: 9
Joined: 10 Aug 2013 23:00

Re: Possible to jump forward based on X subtitle keywords?

Postby joeklow » 26 Aug 2013 02:55

Can anyone share thought, what resolution intf-event provides in Lua for detecting playback position, in milliseconds?

mederi
Big Cone-huna
Big Cone-huna
Posts: 1948
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Possible to jump forward based on X subtitle keywords?

Postby mederi » 26 Aug 2013 21:40

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.

roumieh2000
New Cone
New Cone
Posts: 6
Joined: 03 Oct 2013 17:27

Re: Possible to jump forward based on X subtitle keywords?

Postby roumieh2000 » 03 Oct 2013 17:42

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.

cuttingEdge
New Cone
New Cone
Posts: 1
Joined: 18 Oct 2013 02:10

Re: Possible to jump forward based on X subtitle keywords?

Postby cuttingEdge » 18 Oct 2013 02:28

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.

evilperro
New Cone
New Cone
Posts: 9
Joined: 10 Mar 2013 17:50

Re: Possible to jump forward based on X subtitle keywords?

Postby evilperro » 18 Oct 2013 14:17

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.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 3 guests