0

The task is to make a jlabel running on the videocanvas. JLabel should be transparent without any background.

I found the answer here: Painting over JMF component It works perfectly on... at least with my webcam. But when I try to replace the source with a usual videofile i begin to experience a problem:

http://clip2net.com/clip/m25721/1305648619-clip-6kb.png

The video plays still good (strange - but i can't capture the video - it's black on screen but still good in reality), but the background appeared under my JLabel. It's format: 176*144 (4:3), MPG1 = MPEG 1 (VCD).

I opened another old video 160*120 (4:3), IV41 = Intel Indeo R4.1. Hm - I made a screen and it works fine - we have no bkacground as expected.

http://clip2net.com/clip/m25721/1305649256-clip-50kb.jpg

I experimented more and more - and got positive result without background with IV50 = Intel Indeo R5.1, IV32 = Intel Indeo R3.2, IV41 = Intel Indeo R4.1 and... DIVX = OpenDivx v4. All common mpegs are playing bad (with gray background under JLabel).

Maybe there are another way for drawing jlabel over the video? Or this method could be fixed - help please.

I just added JLabel to the code above in that way:

JLabel jl = new JLabel();
jl.setText("This is my JLabel that will cross the videoframe");
jl.setBounds(50,50,300,50);
jLP.add(jl, 0);
Community
  • 1
  • 1
Malex
  • 180
  • 1
  • 8

1 Answers1

0

Try painting the JLabel to a BufferedImage as I do in this LabelRenderTest.java source. Then paint the image on the video.

The image can then be drawn wherever it needs to be seen. Cache it and draw in different places in each frame to simulate text scrolling.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Is it a good idea to recreate a buffered image for every videoframe? The text will move - so i need to recreate also a bi buffered image. – Malex May 18 '11 at 00:54
  • @Malex: "The text will move - so i need to recreate also a bi buffered image." Of course not! See the edit to my answer. In the linked source, the image of the `JLabel` was called `bi` & drawn at location 20,20. Make that a class attribute and draw it wherever & whenever you like. – Andrew Thompson May 18 '11 at 01:33
  • Nope. It doesn't work at all. I still got the rectangle shadow. Maybe I should try to use an image - not a jlabel? I can post the entire code if neded. – Malex May 22 '11 at 19:19
  • @Malex: "Maybe I should try to use an image - not a jlabel?" That is what I have been suggesting from the **start.** "I can post the entire code if neded." No, don't do that. You have a slight chance of someone looking at an [SSCCE](http://pscode.org/sscce.html). – Andrew Thompson May 22 '11 at 21:42