2

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.

0
2

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
5
  • Sadly, I wasn't able to get anywhere near as good of a compression ratio using ffv1 as using libx264. I assume this was because ffv1 is intra-frame and not inter-frame. Also, qtrle ended up turning the 4.51GB of PNG files into a a 16GB video file. Is there some version of ffv1 that uses inter frame compression? – jippyjoe4 Dec 5 '19 at 0:58
  • @llogan, do you know of any that use interframe compression and support an alpha channel? They seem to be mutually exclusive in my search. – ereHsaWyhsipS Dec 9 '19 at 4:34
  • @ereHsaWyhsipS Perhaps VP9 lossless mode will address your needs. It will require a RGB to YUV conversion as it only supports yuva420p in regards to alpha which may or may not concern you. – llogan Dec 9 '19 at 20:47
  • @llogan, unfortunately, the conversion to YUVA420 is a bit of a deal breaker. It really seems difficult to find the right codec. – ereHsaWyhsipS Dec 18 '19 at 20:40
  • @ereHsaWyhsipS Unfortunately there may not yet be a perfect solution to fulfill your requirements. – llogan Dec 18 '19 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.