Page 1 of 1

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

Posted: 26 Jan 2010 14:59
by hector2
*************************************
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 !

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

Posted: 06 Feb 2010 18:20
by hector2
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 !

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

Posted: 16 Feb 2010 20:15
by hector2
I found it in intf/rc.lua :D

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

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

Posted: 07 Mar 2010 15:07
by hector2
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 .

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

Posted: 07 Mar 2010 17:48
by Jean-Baptiste Kempf
Cool, hopefully, we will have a cool website for those soon. :D

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

Posted: 07 Mar 2010 19:04
by hector2
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 !

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

Posted: 06 Jul 2010 11:06
by ivoire
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.

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

Posted: 22 Jul 2010 20:06
by salman
how to put my channel logo on live stremaing???????????????????????

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

Posted: 05 Aug 2010 14:37
by ivoire
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).

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

Posted: 05 Aug 2010 20:25
by hector2
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...

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

Posted: 06 Aug 2010 15:43
by ivoire
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.

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

Posted: 01 Oct 2010 15:00
by hector2
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 !

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

Posted: 01 Oct 2010 16:00
by ivoire
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

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

Posted: 08 Jan 2012 21:19
by laplasz
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,

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

Posted: 08 Jan 2012 23:05
by hector2
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 )

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

Posted: 09 Jan 2012 23:59
by laplasz
Hi!

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

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

Posted: 16 Jan 2012 21:10
by hector2
Still alife ? :wink: