[Extension] subtitler >> External / Dual subtitles

Discuss your Lua playlist, album art and interface scripts.
laixix
New Cone
New Cone
Posts: 6
Joined: 27 Jan 2013 21:03

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby laixix » 28 Jan 2013 16:20

could you recommend me any linux distribution which worked well the extension?

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 29 Jan 2013 13:15


laixix
New Cone
New Cone
Posts: 6
Joined: 27 Jan 2013 21:03

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby laixix » 29 Jan 2013 17:05

Thanks for your willingness mederi, really thank these people need in the community like you, and Realise an investigation and made a compilation of various resources to program in lua may be able to serve anyone, I will begin to change and other extensions.these are

http://www.lua.org/faq.html
viewtopic.php?f=29&t=97639&start=20
http://www.linuxjournal.com/article/9605

http://comments.gmane.org/gmane.comp.vi ... evel/82484

hope will be of great help ..


flipside5
New Cone
New Cone
Posts: 8
Joined: 19 Feb 2013 22:52

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby flipside5 » 21 Feb 2013 00:02

Thanks for your work on this, mederi. The extension is very helpful. Before I came across your extension, I found this one. It doesn't work with the current version of VLC, but I thought I would mention in to you, anyway, in case the code the code is of any help to you.

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 22 Feb 2013 14:44

@flipside5
Thanks for the tip. The script combines 2 external subtitle files (SRT/SUB/ASS) into one ASS subtitle file. It is a good idea, but I am no sure about the proper support of ASS subtitles in VLC. There are already couple of similar external tools on the Internet. It would be nice to have such a feature directly in VLC: dual subtitles, 3D SBS/TOB subtitles.

flipside5
New Cone
New Cone
Posts: 8
Joined: 19 Feb 2013 22:52

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby flipside5 » 23 Feb 2013 13:28

Yes it would be very handy if it were added into VLC. It seems to be something that people have been asking for for a long time. I also came across this ticket, which goes back 6 years. But until something added to the official build, your script is proving very helpful.

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 22 Apr 2013 21:11

Proposal for a low tech subtitles sync solution >> You can test the idea within Subtitler (lite):

Code: Select all

-- find line starting with "vlc.var.add_callback" and add following new line there: vlc.var.add_callback( vlc.object.libvlc(), "key-pressed", key_press ) -- find line with "vlc.var.del_callback" and add following new line there: vlc.var.del_callback( vlc.object.libvlc(), "key-pressed", key_press ) -- edit "if actual_time>=v[1] and actual_time<=v[2] then" line to this: if actual_time>=v[1]+delay and actual_time<=v[2]+delay then -- edit "if actual_time<subtitle[1] or actual_time>subtitle[2] then" line to this: if actual_time<subtitle[1]+delay or actual_time>subtitle[2]+delay then -- add following new lines at the end of the script: delay=0 function key_press( var, old, new, data ) local actual_time = vlc.var.get(vlc.object.input(), "time") if new==33554536 then at=actual_time end -- Shift+h -- audio timestamp if new==33554538 then st=actual_time end -- Shift+j -- subtitle timestamp if new==33554539 then delay=at-st end -- Shift+k -- +/-delay end
Shift+h takes audio timestamp
Shift+j takes subtitle timestamp
Shift+k calculates (applies) subtitle delay (+/- value)

--- EDIT 26.4.2013 ---
Or rather "delay=delay+at-st" for continuous adjustment? And also some reset hotkey? Now paused video and pressing of Shift+h then Shift+j then Shift+k work as reset.

pthomet
New Cone
New Cone
Posts: 5
Joined: 06 Apr 2013 13:02

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby pthomet » 26 Apr 2013 00:53

Oops, mederi,

I forgot to post an update to my query on the forum.
I have posted a patch to the devel mailing list that adresses my suggestion, and it has been accepted in the main repo : see the patch at
http://mailman.videolan.org/pipermail/v ... 92671.html

Added the following shortcuts (and made them configurable):
- Shift-H: sets a timestamp bookmark on the audio
- Shift-J: sets a timestamp bookmark on the subtitle
- Shift-K: corrects the delay between both bookmarks
- Command-Shift-K: resets the delay

Many thanks for your kind attention anyway, and I will look at your extension,
since I have other ideas concerning subtitles sync that could be easier done with it :-)

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 26 Apr 2013 10:32

@pthomet
I plan to implement also user-friendly controls and also new features in dialog box in this extension, but I am not sure about the future functionality of Lua extensions in VLC. Please can you look at the Ticket #8097 Lua Extensions, VLC2.1: var.add_callback( ), var.del_callback( ) do not work whether you could help to do something about it? So far I have discovered, that I can use callbacks for adding custom hotkeys in extension, for doing something periodically during playback and for responding to mouse clicks on the screen of the playing video. So it is very useful feature.

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 09 Jun 2013 14:33

I have just tried to implement "Jump to next subtitle" idea. Just add following lines for right/left arrow hotkeys in the function key_press( var, old, new, data ):

Code: Select all

if new==2228224 then -- right arrow -- jump to next subtitle local input = vlc.object.input() local actual_time = vlc.var.get(input, "time") for i,v in pairs(subtitles) do if actual_time<v[1]+delay then vlc.var.set(input, "time", v[1]+delay) break end end end if new==2162688 then -- left arrow -- jump to previous subtitle end

mohsen796
New Cone
New Cone
Posts: 4
Joined: 08 Jun 2013 12:48

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mohsen796 » 10 Jun 2013 13:17

tanks alot mederi
but i did not understand were should i add this code

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 10 Jun 2013 13:59

First you need to download the script "Subtitler (lite).lua", install it by putting it in the right directory, set it up by editing the script in some text editor and follow instructions. Once the extension works then enhance its functionality by adding lines of code for subtitles synchronisation with hotkeys (read comments in the code: -- ...) and then add the lines for right arrow key for jump to next subtitle ( if new==2228224 ...).

zhangweiwu
New Cone
New Cone
Posts: 2
Joined: 15 Feb 2013 10:33

Re: VLC Extension: subtitler

Postby zhangweiwu » 06 Oct 2013 16:06

I have just tried VLC 2. You probably mean improved detailed settings for subtitles and output rendering. That is much better now. But it still cannot play multiple independent (each uses own proper encoding) subtitles at the same time.
Ah, do you mean that VLC 2 can actually play multiple subtitles if they are encoded the same way and are not independent, i.e. put in the same file (e.g. both are in the same .sub or both in the same .mkv file)? I spent my one hour time to do this homework and didn't find a way to do so with Google.

Just a few weeks after laconic Jean-Baptiste Kempf suggested you to try VLC 2.0.0, he himself replied another post asking for dual-subtitle with: "This is not possible yet." I, like you, meditated for a while of the deep sense of his words, and concluded that he didn't mean there is a multi subtitle feature in VLC 2.0.0 after all.

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 06 Oct 2013 20:53

You have probably not read the whole story here. The VLC Extension for playing another subtitles (SRT) in VLC-2.0.x is published here: Subtitler (lite). VLC plays one subtitle the usal way, the another subtitle is played by the extension.

flipside5
New Cone
New Cone
Posts: 8
Joined: 19 Feb 2013 22:52

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby flipside5 » 15 Jul 2014 04:42

Hello again mederi,

I've just returned to using your extension after a long break. This time, I don't seem to be able to get it working correctly. The only way I can get it to display any kind of subtitle is like this:

1. Click the "subtitler (lite) mod" option at the bottom of the View menu. That causes a refresh button to display on the screen.
2. When somebody is speaking click on the refresh.

That method gets the subtitle for the current line of dialogue to display on the screen. But after that it doesn't display anything else.

If you could advise me how to sort this out, so that it displays all of the subtitles, I'd be very grateful.

I'm using VLC 2.1.3

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 15 Jul 2014 12:15

Press and hold "Enter" key or keep clicking on the [Refresh] button in the dialog window :-) Use some "keypresser" or "keysender", an external application that is able to send "Enter" keystrokes to "Subtitler (lite) mod" window in certain time interval (about 100 ms) automatically. I have written and enclosed a simple VBScript for Windows users. Linux users could find some application on the Internet and share their recommendation right here.

flipside5
New Cone
New Cone
Posts: 8
Joined: 19 Feb 2013 22:52

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby flipside5 » 15 Jul 2014 12:29

OK. Thanks. I'll see about setting something up with autohotkey. Has something happened in a recent release of VLC to make this necessary? I don't recall it working like that before.

flipside5
New Cone
New Cone
Posts: 8
Joined: 19 Feb 2013 22:52

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby flipside5 » 15 Jul 2014 14:47

Here's my autohotkey script, in case anyone is interested.
To use it:

1. Installl autohotkey
2. Copy the code below into notepad, or something similar.
3. Save it somewhere with an extension of ahk. E.g. subtitlerlite.ahk
4. Double click on the saved file.
5. Start merdi's extension (in the View menu, click "subtitler (lite) mod")
5. Press Win+s. (i.e. press Windows Key/Start button at the same time you press the "s" key). This will start automatically clicking the refresh button for merderi's script.
6. If you want to use ctrl-s instead of Win-s, change the second line to be this:

Code: Select all

!s:: ;set hotkey to ctrl+s
That is, replace # with !
You can set the hotkey to be anything you like, as described here.

Thanks to mederi for all of his hard work on this.

Code: Select all

#Persistent #s::  ;set hotkey to Win+s IfWinExist, Subtitler (lite) mod {     MsgBox,64,Autohotkey Script started,Autohotkey Script started.Subtitler lite button will be pressed 10 times per second,5     While WinExist(Subtitler (lite) mod)        {        WinActivate Subtitler (lite) mod        Send {Enter}        Sleep, 100        }     MsgBox,0,Autohotkey Script ending,Autohotkey script ending. Press Win+s to restart,4 } else {    MsgBox,0, Error, Couldn't find window with title "Subtitler (lite) mod". Press Win+s to try again. } Return

roland1
Blank Cone
Blank Cone
Posts: 44
Joined: 01 May 2014 16:49

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby roland1 » 15 Jul 2014 20:48

To circumvent global binding I suggest the use of #directives, maybe so :)

Code: Select all

#IfWinExist, Subtitler (lite) mod #s:: ;set hotkey to Win+s MsgBox,64,Autohotkey Script started,Autohotkey Script started.Subtitler lite button will be pressed 10 times per second,5 While WinExist(Subtitler (lite) mod) { WinActivate Subtitler (lite) mod Send {Enter} Sleep, 100 } MsgBox,0,Autohotkey Script ending,Autohotkey script ending. Press Win+s to restart,4 Return #IfWinExist

flipside5
New Cone
New Cone
Posts: 8
Joined: 19 Feb 2013 22:52

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby flipside5 » 15 Jul 2014 20:56

Sounds good to me. I don't quite understand how it all works, but I'm sure you know more about ahk than I do!

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 25 Jul 2014 16:42

Is it possible to send a keystroke to an inactive window (without activating the "Subtitler (lite) mod" window)?
Is it possible to remember current active application (window), then temporarily activate a dialog box of some VLC Lua Extension and then reactivate the previous application using the AutoHotkey?

roland1
Blank Cone
Blank Cone
Posts: 44
Joined: 01 May 2014 16:49

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby roland1 » 25 Jul 2014 17:42

Probably Yes to all. Related commands/functions are controlsend, winexist(), winactivate.
Also see:
http://www.autohotkey.com/docs/commands.htm
To get the necessary window/control identifiers (ClassNN etc) run window spy (which (at least) was part of the ahk installation). Controlsend can be a show stopper, so, starting with it is advised.

danielgr
New Cone
New Cone
Posts: 2
Joined: 30 Nov 2014 03:06

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby danielgr » 30 Nov 2014 03:14

Hi there,
First of all, thanks so much for developping this add-on.
I've been struggling for years with this problem, and I'm incredibly glad to finally have found a relatively simple way, if not very elegant, but so much better than nothing !

So I just wanted to add my two cents.
I tried the AutoHotKey script in my W10 Preview machine and it was not working, so instead I tried a couple of utilities I found on the net:
* Auto Key Presser
* Key Presser .

The first one works, but it's annoying because one cannot set up an initial delay to start pressing the (enter) key, so subtitles are always a bit late.

The second one is my current choice, because it allows you to select the window you want to press the key, as well as an initial delay and interval.

So anyway, just thought I would share.

Thanks again for developing the add-on !!!

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

Re: VLC Extension: subtitler >> External / Dual subtitles

Postby mederi » 02 Dec 2014 13:59

Doesn't the included "keypresser.vbs" work for you? I think that VBS scripts should work in all Windows. You just play a film, pause it if you want, activate the "Subtitler (lite) mod" extension, start the "keypresser.vbs", unpause the film by clicking Play/Pause control button, double-click the playing video for full screen mode, enjoy. And you would still be able to control playback (pause/play, rewind, ...) with mouse. You could have the initial delay, too. Just edit the script and prepend following new line for 10 seconds delay:

Code: Select all

WScript.Sleep 10000
The suggested Key Presser 1.3 is good one, but it does not work for me if "Subtitler (lite) mod" window does not have focus.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 3 guests