Page 1 of 1

VLCJ and custom painting on top of a Java component

Posted: 13 Apr 2010 15:48
by dhirwinjr
All,

I’m using JNA in combination with VLC to embed video within a standard Java application. In particular I’m using VLCJ (http://code.google.com/p/vlcj/) to provide a binding between Java and the VLC libraries. Here’s a quick summary of how video is started on a java.awt.Canvas object:

Code: Select all

java.awt.Canvas videoSurface = new MyCustomCanvas(); … long drawable = Native.getComponentID(videoSurface); libvlc_exception_t exception = new libvlc_exception_t(); libvlc.libvlc_media_player_set_drawable(mediaPlayerInstance, (int) drawable, exception);
I have no problem getting video to play and stop but what I’d like to also be able to do is add some custom painting on top of the java.awt.Canvas object (for example, draw some lines or text on top of the video). I tried to override the paint(Graphics g) method within the java.awt.Canvas object but when the video actually starts it appears that the video sits on top of my custom painting and in turn you don’t see the custom painting.

I don't think this really is an issue at all with VLC (and I do have a support question into the folks at JNA and VLCJ) but I thought I’d throw it out there and see if anyone had any suggestions or ideas.

Thanks,
Dave Irwin

Re: VLCJ and custom painting on top of a Java component

Posted: 13 Apr 2010 17:10
by Rémi Denis-Courmont
That depends on the video driver. Usually disabling the hardware overlay fixes this (but explodes the VLC CPU consumption).

Re: VLCJ and custom painting on top of a Java component

Posted: 13 Apr 2010 18:38
by dhirwinjr
That depends on the video driver. Usually disabling the hardware overlay fixes this (but explodes the VLC CPU consumption).
Thanks for the response. Just to confirm, I assume that this is video driver specific and outside the scope of the VLC configuration and/or properties. For me this means:

- video driver vendor specific setting
- can't easily set this via VLC meaning a user would need to manually change it on their system
- in turn this is not something easily manageable from a central location

Dave

Re: VLCJ and custom painting on top of a Java component

Posted: 13 Apr 2010 18:45
by Rémi Denis-Courmont
You can set the --no-overlay option on all platforms but MacOS. However, whether you need to set this option depends on the video driver and hardware.

Unfortunately, turning overlay off increases CPU and main memory consumption a lot, as scaling and chroma conversion must then be done in software. In principle, using a video filter is strongly recommended over drawing a custom widget. Video filter can modify the decoded pictures in native resolution and chroma before they're rendered. This avoids having to disable the hardware acceleration.