3

Suppose I have a sequence of PNG image files which may or may not contain an alpha channel (assume those that do have an alpha channel actually utilize it). While PNG files themselves have their own lossless compression, I can usually get much smaller filesizes by using lossless video codecs, such as x264. For example:

ffmpeg -framerate 60 -i out%04d.png -c:v libx264rgb -qp 0 out.mp4

has given me significant file savings over storing the original PNG files separately (1.92GB video file vs 4.51GB separately). However, I do not believe that this supports alpha channels, so I can't always use this codec. Ideally, I could find one codec that works in both scenarios (alpha and no alpha).

Do you know of an alternative lossless codec I can use that would give similar space savings while still supporting alpha channels? If you do but it isn't perfectly lossless, I'm willing to look at near-lossless alternatives as well.

1 Answers1

4

ffv1: FFmpeg video codec #1

This format is becoming the standard for the archival community. Lossless and supports RGB and variants + alpha:

ffmpeg -h encoder=ffv1
[...]
Supported pixel formats: yuv420p yuva420p yuva422p yuv444p yuva444p yuv440p yuv422p yuv411p yuv410p bgr0 *bgra* yuv420p16le yuv422p16le yuv444p16le yuv444p9le yuv422p9le yuv420p9le yuv420p10le yuv422p10le yuv444p10le yuv420p12le yuv422p12le yuv444p12le yuva444p16le yuva422p16le yuva420p16le yuva444p10le yuva422p10le yuva420p10le yuva444p9le yuva422p9le yuva420p9le gray16le gray gbrp9le gbrp10le gbrp12le gbrp14le gbrap10le gbrap12le ya8 gray10le gray12le gbrp16le rgb48le gbrap16le rgba64le gray9le yuv420p14le yuv422p14le yuv444p14le yuv440p10le yuv440p12le

Basic example command:

ffmpeg -framerate 60 -i out%04d.png -c:v ffv1 out.mkv

No need to manually select a pixel format: it should automatically choose the most appropriate one.

See FFmpeg Wiki: FFv1 for more info.

qtrle: QuickTime Animation (RLE) video

Simpler and older than FFv1, but may be supported by your editing software. Lossless and supports RGB + alpha:

ffmpeg -h encoder=qtrle
[...]
Supported pixel formats: rgb24 rgb555be *argb* gray

Basic example command:

ffmpeg -framerate 60 -i out%04d.png -c:v qtrle out.mov

Others

  • utvideo
  • huffyuv
  • ffvhuff
llogan
  • 63,280