Page 1 of 1
Subtitle Access
Posted: 25 Jun 2023 15:43
by jrockow
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.
Re: Subtitle Access
Posted: 25 Jun 2023 19:38
by Rémi Denis-Courmont
That hotkey just flips through the available subtitle tracks.
Re: Subtitle Access
Posted: 26 Jun 2023 02:50
by jrockow
Right, that's exactly what I want to do.
Tell me how I can do that with Python.
Re: Subtitle Access
Posted: 26 Jun 2023 14:04
by Lotesdelere
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.
Re: Subtitle Access
Posted: 26 Jun 2023 21:32
by jrockow
You guys are missing the point.
I need to know how to pass the 'v' to VLC via a Python command.
Re: Subtitle Access
Posted: 27 Jun 2023 06:48
by Rémi Denis-Courmont
That's in the API documentation.
Re: Subtitle Access
Posted: 27 Jun 2023 19:10
by jrockow
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.
Re: Subtitle Access
Posted: 29 Jun 2023 17:07
by unidan
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
Re: Subtitle Access
Posted: 02 Jul 2023 23:59
by jrockow
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?
Re: Subtitle Access
Posted: 05 Jul 2023 10:12
by mfkl
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/
Re: Subtitle Access
Posted: 07 Jul 2023 03:55
by jrockow
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.