VLCJ and custom painting on top of a Java component

This forum is about all development around libVLC.
dhirwinjr
Blank Cone
Blank Cone
Posts: 35
Joined: 14 Jan 2008 17:46
Operating System: Windows / Linux

VLCJ and custom painting on top of a Java component

Postby dhirwinjr » 13 Apr 2010 15:48

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

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

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

Postby Rémi Denis-Courmont » 13 Apr 2010 17:10

That depends on the video driver. Usually disabling the hardware overlay fixes this (but explodes the VLC CPU consumption).
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

dhirwinjr
Blank Cone
Blank Cone
Posts: 35
Joined: 14 Jan 2008 17:46
Operating System: Windows / Linux

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

Postby dhirwinjr » 13 Apr 2010 18:38

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

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

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

Postby Rémi Denis-Courmont » 13 Apr 2010 18:45

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.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests