Search code examples
ffmpegtransparency

How to extract a single frame while retenaing transparency from a transparent video


I'm trying to extract a single frame from a transparent webm video while retaining transparency.

I tried doing this:

ffmpeg -i input.webm -frames:v 1 -pix_fmt rgba output.png 

This extracts a frame with a white background and no transparency.


Solution

  • You need a FFmpeg build with libvpx support.

    You can then override the default decoder to correctly retrieve the alpha channel.

    VP8:

    ffmpeg -codec:v libvpx -i input.webm [...]
    

    VP9:

    ffmpeg -codec:v libvpx-vp9 -i input.webm [...]