3

I typically deal with many high-resolution PNG sequences, many of which are RGB (24-bit) or entirely grayscale (8-bit). Because adjacent frames in the sequences are very similar, it is important that I compress them losslessly using a codec that supports inter-frame compression. I've used libx264 to compress the RGB 24 bit sequences with decent success (specifically ffmpeg -framerate 60 -i out%04d.png -c:v libx264rgb -qp 0 out.mp4), and while I can do the same for the grayscale images, I'm wondering if there's a better codec to use in that case given that there's only one channel instead of three.

Is there a better alternative codec than libx264 for grayscale png sequences specifically? If so, why is it better? If not, why is libx264 the best in both cases?

1 Answers1

3

libx264 and libx265 both have lossless modes, are inter-frame, and support the gray pixel format.

libx264

libx264 supports the gray pixel format (see ffmpeg -h encoder=libx264), so using that instead of libx264rgb may be a more appropriate choice for the grayscale inputs:

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

libx265

Worth trying to compare with libx264, but it will be much slower to encode (especially if you use a slow preset):

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

others

ffv1, huffyuv, ffvhuff, qtrle are all lossless and support gray pixel format(s), but these are are all intra-frame.

llogan
  • 63,280