Pull one frame out of a transparent WebM with a plain ffmpeg -i, read its alpha channel, and every pixel can come back at 255. That looks exactly like a broken export, and the obvious next move is to blame whatever produced the file. In this run the file was fine. The same WebM, decoded with -c:v libvpx-vp9 placed in front of the input, gave alpha values from 0 to 255, with 78.4% of the frame fully transparent. The only thing that changed between the two results was which decoder FFmpeg picked.
Two decodes of one transparent WebM
The file is a 3-second, 540×960 clip of a person in front of a green screen, with the background removed. That step was done with the video matting Beta in ImgIng https://imging.ai/ , which runs in a desktop browser on the machine itself; with a transparent background selected, WebM (VP9 with alpha) is its only export. Where footage is supposed to stay inside the company network, the local part is the first thing worth checking, and the network capture taken while it processed showed no request uploading the video. That is what this capture saw, not a guarantee for every setup. The footage is not mine either: the green-screen clip comes from Wikimedia Commons, by VOA Learning English, in the public domain, and was trimmed and re-encoded for the test.
Both commands pull frame 45, which is 1.5 seconds in, as an RGBA PNG. The decoder option in front of -i is the only difference:
$ ffmpeg -i out.webm -vf "select=eq(n\,45),format=rgba" -vframes 1 a.png
$ ffmpeg -c:v libvpx-vp9 -i out.webm -vf "select=eq(n\,45),format=rgba" -vframes 1 b.png
Reading the alpha channel of the two PNGs on an Apple-silicon Mac with FFmpeg 9.0, one frame, one run:
| Decoder | Alpha min | Alpha max | Share of pixels at alpha 0 |
|---|---|---|---|
FFmpeg default vp9
|
255 | 255 | 0.0 |
libvpx-vp9 |
0 | 255 | 0.784 |
Why the default decoder misses the alpha
Everything in this section is inference. The decoder source was not read for this, and none of it was tested beyond the two decodes above. My understanding is that VP9 has no alpha plane of its own, so the encoder writes alpha as a second VP9 stream tucked into per-block side data, and alpha_mode=1 is the container saying that side data exists. If that is right, FFmpeg's native vp9 decoder decodes only the color stream and hands back yuv420p frames, and format=rgba then fills alpha with 255. The libvpx wrapper appears to read the side data and return frames that carry alpha. If any of this is wrong in the details, the measured part still stands: one file, two decoders, two different alpha channels.
Put the decoder flag in front of the input
Position matters for -c:v. Before -i it chooses the decoder for that input; after the input it chooses the encoder for the output, which does nothing for this problem. In a pipeline that accepts transparent WebMs from other tools, I'd want two guards rather than one. The first is to probe the stream tags and, when alpha_mode=1 shows up, add -c:v libvpx-vp9 ahead of that input. The second is to decode one sample frame and count how many pixels sit at alpha 0. A matted clip that reads 0.0 there has the same symptom as the first row of the table, and this check also catches the flag landing on the wrong side of -i, which reading the command line will not.
Only single-frame extraction was covered. An overlay onto a new background, or a re-encode that reads the WebM through the default decoder, was not tested; my guess is they receive the same opaque frames, since the filters only see what the decoder hands them. Browser playback of the file was not checked in this run, and neither was any FFmpeg version other than 9.0.
Top comments (0)