Page 1 of 1
media_player_add_slave does not show SRT subtitle
Posted: 03 Oct 2019 21:52
by GreaterDane
Hi,
I can only get libVLC to play my SRT subtitles when the filename exactly matches the video filename, even when I explicitly load the subtitle file like so:
Code: Select all
// libvlcpp binding calls libvlc_media_player_add_slave()
m_Player->addSlave(VLC::MediaSlave::Type::Subtitle, subtitleFile, true);
...
m_Player->play();
The addSlave return code is OK, so I'm not sure why loading the SRT in this manner does not work. Please advise!
Re: media_player_add_slave does not show SRT subtitle
Posted: 03 Oct 2019 23:22
by GreaterDane
Our plan is to have multiple possible subtitle files per video. Given this, I'm working around the issue by copying the currently-selected subtitle file to "VideoFileName.srt" before playing in libVLC.
This is very inelegant, though, and I'd prefer a better solution.
Re: media_player_add_slave does not show SRT subtitle
Posted: 04 Oct 2019 22:06
by mangokm40
In case it helps...
I've seen multiple subtitle files, for different languages, titled like this:
nameofmovie.mp4
nameofmovie.en.srt
nameofmovie.fr.srt
nameofmovie.es.srt
VLC then shows the language (English, French, Spanish) as the name of each subtitle.
Re: media_player_add_slave does not show SRT subtitle
Posted: 07 Oct 2019 10:13
by chubinou
hi,
following code should work (in python for my tests, but that the same for C++), beware that vlc_media_slaves_add expect and uri and not a raw path.
Code: Select all
import vlc
i = vlc.Instance()
m = i.media_new_path("/home/pierre/Videos/foo.mkv")
m.slaves_add(vlc.MediaSlaveType.subtitle, 1, "file:///home/pierre/Videos/plop.srt")
mp = i.media_player_new()
mp.set_media(m)
mp.play()
Re: media_player_add_slave does not show SRT subtitle
Posted: 08 Oct 2019 20:25
by GreaterDane
following code should work (in python for my tests, but that the same for C++), beware that vlc_media_slaves_add expect and uri and not a raw path.
Thanks chubinou! I was indeed passing a file path rather than a URI. I'm curious, why was I seeing a successful return? Does vlc_media_slaves_add not attempt to load the URI?
Wish I could edit the topic title, now that I've been shown the error was mine.
Re: media_player_add_slave does not show SRT subtitle
Posted: 09 Oct 2019 09:45
by chubinou
the media is opened when you play it.