I am trying to compress many (up to 2,500) small (300x200 px) grayscale images so the file size is as small as possible. Currently, my bit depth is 4 (16 shades of gray). Image source is surveillance camera at a remote location, and we need to send images over a very slow satellite connection. I am using ImageMagick to convert images to 4 bit depth uncompressed grayscale TIFs. The uncompressed size of each image is around 41 KB. I am able to compress 1,500 of these images to 3MB with 7zip, which is about a 95% reduction. I have also played around with settings on zpaq, but still cannot get any smaller than 3MB. I know this seems small, but again the satellite connection is at kbps speeds and we pay by the minute for airtime.

Because this is a surveillance camera, the images do not change much between pictures, so I have also tried ffmpeg to convert them to a H.264 video, but file size is even larger (I believe this is because H.264 does not support grayscale, so RGB is still present).

Are there any better settings for zpaq that might give better results, or any other ideas?

Thanks in advance

  • What command did you try with ffmpeg? – Gyan Jan 11 '18 at 4:48
  • ffmpeg -i img%04d.tif -vf fps=30 -c:v libx264 -pix_fmt yuv420p out.mp4 – bdoyle159 Jan 11 '18 at 14:35

It is often better to let the algorithm choose the best way to compress. Indexed-color compression is suitable for sharp-edged images. Photographic images are better compressed by standards such as JPEG and MPEG.

I tested the H.264 compression using FFmpeg and a video of swimming pool that I made. First I converted the video to grayscale, 300x200 pixels and 2 fps. So I used 00:12:30 of the video to get 1,500 frames. I obtained the following:

ffmpeg -i input.mp4 -c:v libx264 -crf 30 crf30.mp4

File size: 5.7 MB
Bit rate: 60.7 Kbps
Example frame:
enter image description here

ffmpeg -i input.mp4 -c:v libx264 -crf 40 crf40.mp4

File size: 1.6 MB
Bit rate: 17.2 Kbps
Example frame:
enter image description here

ffmpeg -i input.mp4 -c:v libx264 -crf 45 crf45.mp4

File size: 768.5 kB
Bit rate: 7998 bps
Example frame:
enter image description here

  • Thanks! I went with a similar approach, but first converted the images to 8-bit grayscale with imagemagick, then packaged them in a video with ffmpeg. I don't have the commands I used in front of me, but I used a 2-pass encoding to encode the video to 25kbps. I'm happy with the results of around 200kB per video. – bdoyle159 Jan 13 '18 at 0:34

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.