control subtitle position with libVLC?

This forum is about all development around libVLC.
androbi
New Cone
New Cone
Posts: 5
Joined: 12 Feb 2020 09:53

control subtitle position with libVLC?

Postby androbi » 16 Feb 2020 12:13

Hi all,

I'd like to ask if it is possible to control subtitle position with libVLC?

I would like to develop an app/extension using VLC/libVLC for learning japanese by watching anime. The app/extension shall help with reading/understanding the japanese subtitles (for example by showing readings of Kanji/translations of words etc). This requires the usage of japanese .srt subtitles. These have to be positionable on screen in order to not clash other subtitles that already might be hardcoded into the material. I could do that with VLC and try to do what I need in a lua extension, but these don't seem to be very well suported by VLC anymore. Very limited docs, examples and no help in the forum.

The other way I could go would be using libVLC (ie libVLCSharp) for displaying the video and interact with the player using libVLC. In this case I could also display the necessary information much nicer than with lua. I have found some basic subtitle handling in libVLC but not how to position them. libVLC uses .srt files with the same file name for playback (it shows in the sample I made up), but I can't find a way to configure details like size and position. Setting up key commands for moving the position on screen seems to be limited to win32 and X.

If the subtitle can not be positioned by libVLC which I kind of suspect after going through some VLC code, which other way could I go in order to interface with VLC in the described manner?

Any help highly appreciated!

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

Re: control subtitle position with libVLC?

Postby mfkl » 17 Feb 2020 03:55

Have you tried some of the various subtitles options from https://wiki.videolan.org/VLC_command-line_help/?
https://mfkl.github.io

androbi
New Cone
New Cone
Posts: 5
Joined: 12 Feb 2020 09:53

Re: control subtitle position with libVLC?

Postby androbi » 17 Feb 2020 08:37

Yes, I found that yesterday night, but this requires me to reinstantiate libvlc every time a change to these parameters is necessary, right? Or this there a way to change the command line options with a call to libvlc "on the fly"? I found media.AddOption(), but I could not get it to work, for example

Code: Select all

media.AddOption(":freetype-color=65280");
will not work while "--freetype-color=65280" as an arg to the libVLC constructor will.

It would be ok if the user could change the subtitle position and timing with hotkeys while the video is playing, but I have not been able to configure a hotkey for positioning the subtitle as described on the link you provide, For example this works with vlc: "--global-key-subdelay-up=x" but not with libvlc. The space key toggles play/pause however, without any configuration. Is there a list of the option that libvlc processes or am I doing something wrong?

Restarting libvlc with new command line options is a workaround for the moment, but it is not a nice user experience. I am a bit surprised by this because some options can be set at libvlc startup, but can not be modified afterwards? They are in there somewhere :) How does vlc change libvlc parameters on the fly?

Thanx for your answer!!

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

Re: control subtitle position with libVLC?

Postby mfkl » 18 Feb 2020 04:28

Is there a list of the option that libvlc processes or am I doing something wrong?
Yes, on the link I sent to you. And in the code.
I am a bit surprised by this because some options can be set at libvlc startup, but can not be modified afterwards?
That is correct. Which can be modified afterwards or not is not documented, you will have to check the code. Why this is the way it is is because of either technical reason, or because libvlc does not support it (while the core might).
https://mfkl.github.io

androbi
New Cone
New Cone
Posts: 5
Joined: 12 Feb 2020 09:53

Re: control subtitle position with libVLC?

Postby androbi » 18 Feb 2020 08:00

Yes, on the link I sent to you. And in the code.
So you are saying ALL vlc (the link is about vlc) cmd line options are processed by libvlc? This does not seem to be the case for me as I tried to explain (define hotkeys for example).

Anyhow, it would be great if the user could customize subtitle positon while playing. I don't know if there is a technical path to this other than restarting the player, but it certainly would make applications using libvlc much more flexible.

Thank you very much for your help!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 16 guests