Lossless VP9 Webm Encoding of PNG Sequence with Alpha in FFmpeg

1

I'm trying to encode a sequence of 32-bit 8bpc PNG images (RGB with an alpha channel) using the lossless VP9 codec with ffmpeg; specifically:

ffmpeg -framerate 60 -i out%04d.png -c:v libvpx-vp9 -lossless 1 -pix_fmt yuva420p output.webm

This seems to encode the video losslessly; however, when I run:

ffmpeg -i output.webm out%04d.png

the resulting PNG images that it spits out are missing the alpha channel (they are 24 bit, 8bpc)! What's going wrong here?

These are the files that I'm testing this on if you want to try it for yourself: https://drive.google.com/open?id=1IKThU4X_Ub1IqW-pnhds4Z_KwQEwUMtK

If it helps, I'm using this build of ffmpeg on Windows 10:

  built with gcc 9.1.1 (GCC) 20190621
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.101 / 58. 28.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100```

jippyjoe4

Posted 2019-12-17T22:14:27.283

Reputation: 630

1The conversion form RGB to YUV is not lossless. You are losing data even before you get to VP9. – szatmary – 2019-12-18T00:24:39.757

@szatmary, thank you for pointing that out. – jippyjoe4 – 2019-12-18T17:31:55.977

Answers

1

The native VP9 decoder does not support alpha, so the VPX decoder has to be forced.

ffmpeg -c:v libvpx-vp9 -i output.webm out%04d.png

Gyan

Posted 2019-12-17T22:14:27.283

Reputation: 21 016