Search code examples
vlcvlcj

vlcj media option "--no-overlay" doesn't work?


I would like to turn off vlc's hardware acceleration option to avoid some lagging issue caused by a graphic card's driver bug. I tried to pass in that option in the prepareMedia method. That didn't help (as it would when I did it through command line: vlc --no-overlay 'path-to-video'). It actually even seemed to make the playback a bit more laggy. Below is part of my code to set up the player. I actually tried playMedia("path-to-video","--no-overlay") and that didn't work either.

mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
player = mediaPlayerComponent.getMediaPlayer();
...
player.prepareMedia("path-to-video","--no-overlay");

Solution

  • Some of those options must be passed when creating the MediaPlayerFactory rather than when playing the media - as to why it's like this, well it's just how LibVLC works.

    If you're using EmbeddedMediaPlayerComponent you can do something like this to supply those options:

    mediaPlayerComponent = new EmbeddedMediaPlayerComponent() {
        protected String[] onGetMediaPlayerFactoryArgs() {
            return new String[] {"--no-overlay"};
        }
    }
    

    Note that this will replace the default media player factory arguments so you might like to specify some other ones too - these are the defaults:

    protected static final String[] DEFAULT_FACTORY_ARGUMENTS = {
        "--video-title=vlcj video output",
        "--no-snapshot-preview",
        "--quiet-synchro",
        "--sub-filter=logo:marq",
        "--intf=dummy"
    };
    

    So that is how you set such native VLC options, but whether this particular option will do what you actually want (and without any other side effects) is another matter.