Search code examples
javavlcvlcjmotion-blur

VLCj: How to set motion blur?


I am developing an interactive video player and would like to dynamically set motion blur using VLCj 3.0.1. Since EmbeddedMediaPlayer doesn't provide some kind of setBlur method, I guess I am supposed to use addMediaOptions(String... options).

However, I haven't been able to figure out how to use it. Starting VLC from the command line I would have to add the following parameters --video-filter=motionblur blur-factor=44. Providing the same parameter in an array, doesn't show any effect though. I would be glad, if someone could show me the correct syntax. This is essentially my code:

EmbeddedMediaPlayerComponent vlc = new EmbeddedMediaPlayerComponent();
EmbeddedMediaPlayer player = vlc.getMediaPlayer(); 
player.playMedia(path); 

String[] options = { "video-filter=motionblur", "blur-factor=" + blur }; 
player.addMediaOptions(options);    

Solution

  • In your example code you are adding options after you play the media, that might work in some instances but you should really (generally) just pass them in as additional parameters on your playMedia call.

    However...

    Some of those options that are not directly supported by a LibVLC API function must be passed when you create the LibVLC instance (i.e. the vlcj MediaPlayerFactory) rather than when you play media.

    Since you are using EmeddedMediaPlayerComponent then you should subclass your EmbeddedMediaPlayerComponent and override onGetMediaPlayerFactoryArgs() and pass your motion blur options, along with whatever else you need, there.

    Note that you need to send the exact command-line switches, so you must prefix your options with "--".

    There is an example of doing precisely that in the vlcj Javadoc for EmbeddedMediaPlayerComponent.

    People often ask is there any documentation describing how each of the available VLC options can be set - the short answer is no there is not, and that any use of options like this is totally unsupported and may not work with a future version of VLC/LibVLC.

    Ideally, enabling motion blur would be achievable by a new LibVLC API function, but someone would have to write a patch for VLC to make that happen.