How to get current active Subtitle File path (or URI) value accurately without guess?

Discuss your Lua playlist, album art and interface scripts.
omareg94
New Cone
New Cone
Posts: 4
Joined: 21 Mar 2017 19:18

How to get current active Subtitle File path (or URI) value accurately without guess?

Postby omareg94 » 31 Mar 2017 14:27

Briefly described question:
How could I get current active Subtitle File path value (or URI) accurately without guess?
If you don't have time, you should have gotten my question until this line.

A video may have multiple subtitle files (video.srt, video.eng.srt, video.arb.srt, video.frn.srt, ...). Also the user can load subtitles from a path other than the video's (e.g. if Video Path: "D:/Path/To/Video/Name.mp4" and Loaded Subtitle File Path: "D:/Different/Path/Another Name.srt"). We can guess/expect the Subtitle File path (e.g. Expected Subtitle File Path: "D:/Path/To/Video/Name.srt"). But this may go wrong if the user loaded subtitles from another directory and the subtitle file was of another name than the video's (e.g. Loaded Subtitle File Path: "D:/Different/Path/Another Name.srt").
I use this approach to expect the Subtitle File path:

Code: Select all

decoded_media_uri = vlc.strings.decode_uri(vlc.input.item():uri()) --get loaded video's uri (Value Example: file:///D:/Path/To/Video/Name.mp4) directory_path, filename, file_ext = decoded_media_uri:match("^file:///(.+/)(.+)(%..+)$") --assign loaded video's: directory_path, filename, file_ext expected_srt_file_path = directory_path..filename..".srt" --assign expected_srt_file_path (Value Example: D:/Path/To/Video/Name.srt)
Another drawback, if active subtitles is of any other type (not .srt) (e.g. Loaded Subtitle File Path: "D:/Different/Path/Another Name.sub"), our expectation for the loaded Subtitle File Path will be wrong. What I need to get the loaded Subtitle File path directly/accurately without guess/expectations.

How could I get current active Subtitle File path value accurately without guess? Maybe something similar to the way we get the loaded video's uri, we get the loaded subtitle's uri somehow I need to know.

Thanks in advance! :D

Rémi Denis-Courmont
Developer
Developer
Posts: 15323
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: How to get current active Subtitle File path (or URI) value accurately without guess?

Postby Rémi Denis-Courmont » 06 Apr 2017 17:27

There are no ways to do that. And anyway, the subtitle track(s) can be embedded in the source.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 12 guests