[FFmpeg-user] libswscale: SwsContext to convert YUV -> RGBA with separate alpha matrix

Rodrigo Madera rodrigo.madera at gmail.com
Mon May 9 16:55:18 CEST 2016

Hello everyone,

I'm using libswscale to convert YUV video to RGBA frames, applying a
separate alpha mask to each processed frame. This is to achieve a "video
transparency" effect.

Something like:

for each video frame:
    Create context to convert from YUV to RGBA
    Apply separate alpha mask to fill in alpha values

So basically for each frame I use sws_scale(), and then I have to call my
hand-made alpha_blend() function, which takes the destination frame and
mask bits.

What I was hoping to find with this email is a way to let libswscale do
this for me. Either configured in the SwsContext, or using a special call
or something, I would rather let libswscale handle the bits for me using

The problem here is that the alpha channel is stored completely separated
from the YUV input (and no YUVA is possible here). And this makes me wonder
if I will be able to eliminate alpha_blend() at all.

Thanks for any input,

More information about the ffmpeg-user mailing list