任务是使 jlabel 在 videocanvas 上运行。 JLabel应该是透明的,没有任何背景。
我在这里找到了答案:
通过 JMF 组件进行绘制
它完美地工作在......至少与我的网络摄像头。但是当我尝试用常用的视频文件替换源时,我开始遇到问题:
> http://clip2net.com/clip/m25721/1305648619-clip-6kb.png 视频播放仍然很好(奇怪 - 但我无法捕获视频 - 屏幕上是黑色的,但实际上仍然很好),但背景出现在我的 JLabel 下。其格式:176*144 (4:3),MPG1 = MPEG 1 (VCD)。
我打开了另一个旧视频160*120(4:3),IV41 = Intel Indeo R4.1。嗯 - 我做了一个屏幕,它工作正常 - 我们没有预期的 bkacground。
http://clip2net.com/clip/m25721/1305649256-clip-50kb。 jpg
我进行了越来越多的实验 - 并在没有 IV50 = Intel 背景的情况下得到了积极的结果Indeo R5.1、IV32 = 英特尔 Indeo R3.2、IV41 = 英特尔 Indeo R4.1 和... DIVX = OpenDivx v4。所有常见的 mpeg 播放效果都很差(JLabel 下的灰色背景)。
也许还有另一种方法可以在视频上绘制 jlabel ?或者可以修复此方法 - 请帮忙。
我只是以这种方式将 JLabel 添加到上面的代码中:
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);
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);
发布评论
评论(1)
尝试将
JLabel
绘制到BufferedImage
,就像我在此 LabelRenderTest.java 源。然后在视频上绘制图像。然后可以将图像绘制在任何需要看到的地方。将其缓存并在每个帧的不同位置绘制以模拟文本滚动。
Try painting the
JLabel
to aBufferedImage
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.