[Beta] Script to display a subtitle's word definition in OSD

Discuss your Lua playlist, album art and interface scripts.
hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

[Beta] Script to display a subtitle's word definition in OSD

Postby hector2 » 26 Jan 2010 14:59

*************************************
edit :
new version (october 2010) : can read *.ling dictionary files.
download : http://download.tuxfamily.org/polyglott ... uction.lua
Image
*************************************
version 0.1.5
(Thanks to test and give some remarks...
Many thanks to Ale5000, his script was very helpful for me...)


You must put the file in the folder:
- Linux: ~/.local/share/vlc/lua/extensions/
- Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\
- Windows (current user): %APPDATA%\VLC\lua\extensions\


you have to configure the script for your use; open it and replace parameters strings by yours (as indicated in the script): path of your dict dictionary, etc.
the subtitle file has to be a SUBRIP subtitle ( *.srt) , and have the same name as the movie file, except the extension (.srt), and has to be in the same directory as the movie.
The dictionary has to be a dict+idx file or a *.ling file), and you can find one here or (if french is one of the 2 languages) : here.
After he should appear in the "view" menu.
When you see a word on the current subtitle :
make a pause
use submenus (or right and left arrows on the keyboard) to display (OSD) the definition which interests you.
That's all !

This script was tested on GNU/linux ubuntu10.04 / vlc 1.1.2 .

************************************

Hello,
I try to learn a foreign language watching movies with foreign subtitles (*.srt). However, i would like to have the possibility to quickly (with a remote):
1/make a pause
2/select a word in the current subtitle
3/display its definition (using a dictionary software as stardict).

Do you think it would be realistic with lua ? My first problem is to get the elapsed time in order to determine the current subtitle: how could i do ? I did not see it in http://www.videolan.org/developers/vlc/ ... README.txt

Thanks !
Last edited by hector2 on 01 Oct 2010 14:56, edited 8 times in total.

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: script to display a subtitle's word definition in OSD

Postby hector2 » 06 Feb 2010 18:20

I found a libvlc method which should make what I want : libvlc_media_player_get_time .
Its signature is :
libvlc_time_t libvlc_media_player_get_time ( libvlc_media_player_t * , libvlc_exception_t * )
I saw in the Lua documentation that we could use var.libvlc_command to launch this method, but I do not know how to use it.

Something like this ?
elapsedtime = vlc.var.libvlc_command(libvlc_media_player_get_time, xxx ,yyy)
what should be xxx and yyy ?

Thank a lot for your help !

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: script to display a subtitle's word definition in OSD

Postby hector2 » 16 Feb 2010 20:15

I found it in intf/rc.lua :D

local input = vlc.object.input()
local t = vlc.var.get( input, 'time' )

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: script to display a subtitle's word definition in OSD

Postby hector2 » 07 Mar 2010 15:07

Hello,
Here is a first release : thanks to test and give some remarks...
Many thanks to Ale5000, his script was very helpful for me...

download : http://download.tuxfamily.org/polyglott ... uction.lua

You must put the file in the folder:
- Linux: ~/.local/share/vlc/lua/extensions/
- Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\
- Windows (current user): %APPDATA%\VLC\lua\extensions\


you have to configure the script for your use; open it and replace parameters strings by yours (as indicated in the script): path of your dict dictionary, etc.
the subtitle file has to be a SUBRIP subtitle ( *.srt) , and have the same name as the movie file, except the extension (.srt), and has to be in the same directory as the movie.
The dictionary has to be a dict+idx file or a *.ling file), and you can find one here or (if french is one of the 2 languages) : here.
After he should appear in the "view" menu.
When you see a word on the current subtitle :
make a pause
use submenus (or right and left arrows on the keyboard) to display (OSD) the definition which interests you.
That's all !

This script was tested on GNU/linux ubuntu10.04 / vlc 1.1.2 .
Last edited by hector2 on 01 Oct 2010 14:52, edited 3 times in total.

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

Re: [Beta] Script to display a subtitle's word definition in

Postby Jean-Baptiste Kempf » 07 Mar 2010 17:48

Cool, hopefully, we will have a cool website for those soon. :D
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.

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: [Beta] Script to display a subtitle's word definition in

Postby hector2 » 07 Mar 2010 19:04

cool. :D
The main issue is that the OSD duration is a bit too short for reading a definition.
If somebody knows how to configure it in VLC (or better how to manage it in the LUA script...)
Thanks !

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: [Beta] Script to display a subtitle's word definition in

Postby ivoire » 06 Jul 2010 11:06

This possible to create an osd with the duration you want with vout_OSDText but this function is not binded into lua for the moment, I will try (remember) to add it.

salman
New Cone
New Cone
Posts: 1
Joined: 22 Jul 2010 19:19

Re: [Beta] Script to display a subtitle's word definition in

Postby salman » 22 Jul 2010 20:06

how to put my channel logo on live stremaing???????????????????????

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: [Beta] Script to display a subtitle's word definition in

Postby ivoire » 05 Aug 2010 14:37

I changed vlc.osd.message so it has now some more parameter (optionnal parameters) like duration and position. But I doubt we will backport this in 1.1. Maybe if you really need it (the change isn't too big).

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: [Beta] Script to display a subtitle's word definition in

Postby hector2 » 05 Aug 2010 20:25

Hello, I just come back from holidays. Thanks a lot for your adds, I will make some tests with my script as soon as possible. Of course I would like that it is integrated in 1.1 (since it is a bit hard to read definitions during the default time) but it is up to you...

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: [Beta] Script to display a subtitle's word definition in

Postby ivoire » 06 Aug 2010 15:43

One difference with the previous definition of vlc.osd.message is that you must give the osd channel number (by default 1 if you are not using more channels).
I will see if I can backport this. Not so much applications are using it so that's not really a problem normally.

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: [Beta] Script to display a subtitle's word definition in

Postby hector2 » 01 Oct 2010 15:00

I updated the script (see upon). Please tell me when the modification of osd.message is backported (worst case = vlc 1.2, isn't it ?). Thanks a lot !

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: [Beta] Script to display a subtitle's word definition in

Postby ivoire » 01 Oct 2010 16:00

I cannot backport it to VLC 1.1.x as the OSD system changed a lot. The function needed to choose the position/duration/... are not present in vlc 1.1, only in >1.2

laplasz
New Cone
New Cone
Posts: 3
Joined: 06 Jan 2012 22:34

Re: [Beta] Script to display a subtitle's word definition in

Postby laplasz » 08 Jan 2012 21:19

Hi There!

I found the bug when running when using the script under Windows.
Also I extended the code with supporting xdxf files.

What shoud i do know? where should i put the code?

Thanks,

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: [Beta] Script to display a subtitle's word definition in

Postby hector2 » 08 Jan 2012 23:05

Hello laplasz,
Great !
I don't think you can update here.
The best could be to send me the file and I will do up the update, if you agree. Thanks again !

( contact_/!\_polyglotte__dot__tuxfamily__dot__org )

laplasz
New Cone
New Cone
Posts: 3
Joined: 06 Jan 2012 22:34

Re: [Beta] Script to display a subtitle's word definition in

Postby laplasz » 09 Jan 2012 23:59

Hi!

I will make some comment in the code, then I will send you, maybe tomorrow....

hector2
Blank Cone
Blank Cone
Posts: 17
Joined: 26 Jan 2010 14:36

Re: [Beta] Script to display a subtitle's word definition in

Postby hector2 » 16 Jan 2012 21:10

Still alife ? :wink:


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 3 guests