Page 1 of 1

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

Posted: 31 Mar 2017 14:27
by omareg94
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

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

Posted: 06 Apr 2017 17:27
by RĂ©mi Denis-Courmont
There are no ways to do that. And anyway, the subtitle track(s) can be embedded in the source.