[Qt-interest] Fade In/Out Video with Phonon

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Mon Feb 22 09:53:41 CET 2010


Josiah Bryan wrote on Saturday, February 20, 2010 8:07 PM:

> ... Even with setting contrast down to -1 at
> the same time, video still show through. Going the other way (fade to
> white, or +1.0 brightness) - works  a bit better, but even at 1.0,
> video still legible.

Setting the contrast to -1 (or -100%) does *not* set the video to black: it reduces, well, the contrast by 100% (exactly what the method name implies).

What you want is to set the alpha value from 100% (opaque) to gradually 0% (transparent), so that the underlying surface - black or another video - shines through.

How you do that with Phonon I don't know (I have no experience with that API), but basically you would

- render the video frame on some "surface" (QImage, OpenGL textured rectangle, ...)
- set the alpha value accordingly (1.0 down to 0.0)
- render that "surface" on top of an existing one (black background, other video frame)

Note that alpha-blending images "in realtime" (at say 25 FPS) can be quite CPU intensive, so depending on the video size (PAL, HDTV, ...) and the compression (h.264, ...) which might also use lot of CPU power doing this "in software" can be unsatisfactory. But that would be my first approach, to see what you get with a simple QImage/QPainter approach. Maybe painting onto a QGLWidget with the QPainter API would already improve the performance enough. Otherwise use as much hardware support as you can get (use a Codec which is supported by your graphic hardware, use OpenGL, use Pixel Buffer Objects (PBO) to transfer texture data as quickly as possible into the graphic card memory etc.). Since you want to blend against "black" (instead of another video) maybe there are even more tricks to speedup things).
 

Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list