How to access the elapsed time of VLC when paused? - Java subtitle strings parsing program

325 views Asked by At

I'm writing a java program dealing with parsing text from a subtitle file.

The idea is, whenever I come across a word in the subtitles that I dont know while playing a movie, I pause the video and open my client, then the client accesses the elapsed time, gets the sentence and displays the meanings of all the words in that sentence using some offline dictionary.

I just want to "get the elaspsed time at that instant" - which I think is really basic thing, so I dont want to go through all the documentations of VLC (I tried but I felt like they were too complex and I have no interest in further contributing to VLC open source)

2

There are 2 answers

2
MrSmith42 On

What OS are you using? As far as I can remember on linux VLC (like mplayer) outputs all the time to the console how far the movie is played and also i it is paused.

In this case you could simply redirect this output to the input of your java program which reads it and waits for the "pause" marker. than reads back the last time-stamp.

There might be a better way, but this seams to be the easiest way, without any further research, to me.

0
vafylec On

I wrote a script in AutoHotkey that can retrieve the elapsed time and duration from VLC, via Microsoft Active Accessibility (MSAA).

^q::
WinGet, hWnd, ID, ahk_class QWidget ahk_exe vlc.exe
oAcc := Acc_Get("Object", "4.3.3", 0, "ahk_id " hWnd)
vText := oAcc.accChild(1).accName(0) " / " oAcc.accChild(3).accName(0)
oAcc := ""
MsgBox % vText
Return

You launch the script via Ctrl+Q, and it will output the time in a MsgBox. You can use FileRead and Loop, Parse to find the matching point in a subtitles .srt file for example. Or you could for example append the timestamp to a .txt file using FileAppend and then read that into Java.

To use it:

You install AutoHotkey, maximum around 5 MB of space, save the script as a .ahk file and double-click the file to run, or save it as a .txt file and drag-and-drop it into one of the exe files in C:\Program Files\AutoHotkey. Download link here: AutoHotkey http://ahkscript.org/

Also you would need to download Acc.ahk and put it here: C:\Program Files\AutoHotkey\Lib. Instructions and download link here: Acc library (MSAA) and AccViewer download links - AutoHotkey Community https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

Hope that helps.

Note: this is the sort of script that can potentially break, if VLC do a radical update at some point, but that can be easily readjusted to work correctly again.