[FFmpeg-user] "Extracting" Alpha Channel
Stefano Sabatini
stefano.sabatini-lala at poste.it
Thu Jul 28 11:12:48 CEST 2011
On date Thursday 2011-07-28 12:00:36 +1000, Dan Flett encoded:
> In television graphics or vision mixing, it's often necessary to "extract"
> the alpha channel from a graphics file and turn it into a separate "Key" or
> "Matte" clip.
>
> The Key video is a grayscale representation of the alpha channel - black is
> fully transparent and white is fully opaque.
>
> It is possible to do this the using "lut" filter (I use lutrgb):
>
> -vf "[in] format=rgba, split [T1], fifo, lutrgb=r=minval:g=minval:b=minval,
> [T2] overlay [out]; [T1] fifo, lutrgb=r=maxval:g=maxval:b=maxval [T2]"
>
> This filter first converts the input video to the rgba colorspace.
>
> It then splits the input video into 2 streams (as per the turorial in the
> libavilfter docs). The "background" stream is set to a fully black frame by
> setting the r,g,b values to "minval". The foreground stream is set to a
> fully white frame by setting the r,g,b values to "maxval". In both streams
> the alpha channel is untouched.
>
> At the end of the first stream, the "overlay" filter overlays the white
> stream over the black one, using the untouched alpha channel as the mask.
> The result is a grayscale representation of the alpha channel - the actual
> rgb video content is thrown away.
Another interesting possibility (simpler, faster) would be to
implement a decomposer and a composer filter, for splitting RGBA
channels into separate gray video streams and re-composing them.
More information about the ffmpeg-user
mailing list