Subtitle Access

This forum is about all development around libVLC.
jrockow
New Cone
New Cone
Posts: 6
Joined: 25 Jun 2023 15:35

Subtitle Access

Postby jrockow » 25 Jun 2023 15:43

I have been searching for quite a while to find the correct attribute to toggle thru the subtitles in my Pyhton VLC script.
When I use VLC directly the "v" works as described.
I can find the "play", "pause", "stop" etc., but nothing to toggle the subtitles.
I apologize if this is not the correct forum to ask for help with this.

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

Re: Subtitle Access

Postby Rémi Denis-Courmont » 25 Jun 2023 19:38

That hotkey just flips through the available subtitle tracks.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

jrockow
New Cone
New Cone
Posts: 6
Joined: 25 Jun 2023 15:35

Re: Subtitle Access

Postby jrockow » 26 Jun 2023 02:50

Right, that's exactly what I want to do.
Tell me how I can do that with Python.

Lotesdelere
Cone Master
Cone Master
Posts: 9963
Joined: 08 Sep 2006 04:39
Location: Europe

Re: Subtitle Access

Postby Lotesdelere » 26 Jun 2023 14:04

When I use VLC directly the "v" works as described.
I can find the "play", "pause", "stop" etc., but nothing to toggle the subtitles.

Shift+v to toggle subtitles.

jrockow
New Cone
New Cone
Posts: 6
Joined: 25 Jun 2023 15:35

Re: Subtitle Access

Postby jrockow » 26 Jun 2023 21:32

You guys are missing the point.
I need to know how to pass the 'v' to VLC via a Python command.

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

Re: Subtitle Access

Postby Rémi Denis-Courmont » 27 Jun 2023 06:48

That's in the API documentation.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

jrockow
New Cone
New Cone
Posts: 6
Joined: 25 Jun 2023 15:35

Re: Subtitle Access

Postby jrockow » 27 Jun 2023 19:10

I've looked at the API documentation. I'm just a low-level coder and that's over my head.
I was just hoping there would be someone familiar with the VLC module that could help me.

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: Subtitle Access

Postby unidan » 29 Jun 2023 17:07

Hi, the API changed a bit in 4.0, where this was added:

https://videolan.videolan.me/vlc/group_ ... track.html

In 3.0.x, you could use the following events:

- libvlc_MediaPlayerESAdded
- libvlc_MediaPlayerESDeleted
- libvlc_MediaPlayerESSelected
- libvlc_MediaPlayerESUpdated

(see https://videolan.videolan.me/vlc/group_ ... 2392f62fc6)

As well as those direct functions:

Code: Select all

/** * Get current video subtitle. * * \param p_mi the media player * \return the video subtitle selected, or -1 if none */ LIBVLC_API int libvlc_video_get_spu( libvlc_media_player_t *p_mi ); /** * Get the number of available video subtitles. * * \param p_mi the media player * \return the number of available video subtitles */ LIBVLC_API int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi ); /** * Get the description of available video subtitles. * * \param p_mi the media player * \return list containing description of available video subtitles. * It must be freed with libvlc_track_description_list_release() */ LIBVLC_API libvlc_track_description_t * libvlc_video_get_spu_description( libvlc_media_player_t *p_mi ); /** * Set new video subtitle. * * \param p_mi the media player * \param i_spu video subtitle track to select (i_id from track description) * \return 0 on success, -1 if out of range */ LIBVLC_API int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu );
(from https://code.videolan.org/videolan/vlc/ ... er.h#L1208)

which you can also find in python there: https://www.olivieraubert.net/vlc/pytho ... index.html

jrockow
New Cone
New Cone
Posts: 6
Joined: 25 Jun 2023 15:35

Re: Subtitle Access

Postby jrockow » 02 Jul 2023 23:59

With every ones help and a lot of reading I can finally see my subtitles.
My question now is "can I change the font and/or size of the subtitles"?

Also, how do I exit VLC at the end of the video?

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Subtitle Access

Postby mfkl » 05 Jul 2023 10:12

My question now is "can I change the font and/or size of the subtitles"?
Yes, try adding CLI args from python https://wiki.videolan.org/VLC_command-line_help/
https://mfkl.github.io

jrockow
New Cone
New Cone
Posts: 6
Joined: 25 Jun 2023 15:35

Re: Subtitle Access

Postby jrockow » 07 Jul 2023 03:55

Reading thru the command line help file the closest thing to what I want was "subtitle scaling", at least that's all I can see.
I was hoping for something like a typeface and typesize command.
Let me stress again that I'm a rookie at this, and may have missed your point.
I should also mention that the subtitles I'm working with are imbedded in the .TS file.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 16 guests