media_player_add_slave does not show SRT subtitle

This forum is about all development around libVLC.
GreaterDane
New Cone
New Cone
Posts: 8
Joined: 03 Oct 2019 21:23

media_player_add_slave does not show SRT subtitle

Postby GreaterDane » 03 Oct 2019 21:52

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!

GreaterDane
New Cone
New Cone
Posts: 8
Joined: 03 Oct 2019 21:23

Re: media_player_add_slave does not show SRT subtitle

Postby GreaterDane » 03 Oct 2019 23:22

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.

mangokm40
Cone that earned his stripes
Cone that earned his stripes
Posts: 130
Joined: 20 May 2010 20:00

Re: media_player_add_slave does not show SRT subtitle

Postby mangokm40 » 04 Oct 2019 22:06

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.

chubinou
Developer
Developer
Posts: 521
Joined: 23 Jul 2015 15:19

Re: media_player_add_slave does not show SRT subtitle

Postby chubinou » 07 Oct 2019 10:13

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()

GreaterDane
New Cone
New Cone
Posts: 8
Joined: 03 Oct 2019 21:23

Re: media_player_add_slave does not show SRT subtitle

Postby GreaterDane » 08 Oct 2019 20:25

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.

chubinou
Developer
Developer
Posts: 521
Joined: 23 Jul 2015 15:19

Re: media_player_add_slave does not show SRT subtitle

Postby chubinou » 09 Oct 2019 09:45

the media is opened when you play it.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests