2

Suppose I have a sequence of 32-bit (RGBa) PNG files. Is it possible to compress the RGB channel with one codec and the alpha channel with another? For example, if I had the RGB and alpha as separate PNG files (24 and 8 bit, respectively), I would do something like this:

ffmpeg -framerate 60 -i 24_bit_rgb%04d.png -c:v libx264rgb -qp 0 -preset veryslow rgb.mp4`

ffmpeg -framerate 60 -i 8_bit_alpha%04d.png -c:v libx265 -x265-params lossless=1 alpha.mp4`

But I’m not sure how I’d do this since I don’t have separate RGB and alpha PNG files. Can this be done in FFmpeg?

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
joejoejoejoe4
  • 1,438
  • 9
  • 25
  • 48
  • While this might have an answer, what is the ultimate question here? To me, it reads a bit like an [XY problem](http://xyproblem.info) where you have a goal, have decided this is the solution and want us to provide validity to this solution, but the “solution” might not actually solve your ultimate goal. – Giacomo1968 Jan 15 '20 at 21:33

1 Answers1

3

Use the alphaextract or extractplanes filters.

ffmpeg -i %04d.png -filter_complex "alphaextract[alf]" -map "[alf]" -c:v libx265 -x265-params lossless=1 alpha.mp4 -map 0 -c:v libx264rgb -qp 0 -preset veryslow rgb.mp4
llogan
  • 57,139
  • 15
  • 118
  • 145