Optimizing ffmpeg settings for high-entropy / HIGH-DETAIL ANIMATIONS towards uploading to youtube Based on this older question, I am looking for a good &quot;transfer video codec / compression&quot; for rendering videos from BMPs and/or PNGs and uploading them to Youtube. I am dealing with a lot of entropy / details in my frames.
I built a small Python framework called &quot;bewegung&quot; around ffmpeg and a bunch of Python visualization libraries for animating scientific data. I am calling ffmpeg as follows, writing BMPs directly to stdin:
codec = subprocess.Popen([
    'ffmpeg',
    '-y', # force overwrite of output file
    '-framerate', f'{self.fps:d}',
    '-f', 'image2pipe', # force input format
    '-i', '-', # data from stdin
    '-vcodec', 'bmp', # input codec
    '-s:v', f'{self._width:d}x{self._height:d}',
    '-c:v', 'libx264',
    '-preset', 'veryslow',
    '-crf', '0',
    video_fn,
    ], stdin = PIPE, stdout = PIPE, stderr = PIPE,)

I originally started with PNGs, but the extra compression/decompression steps simply required too much time. BMPs are faster. The BMPs are using 24 bit RGB.
For content based on a few lines and polygons, this works just fine.

When attempting to visualize content with lots of details, points / dots, for instance (in combination with change of contrast and/or color), I am running into several problems:

The above example is based on roughly 1M points, aggregated into a density plot. During fade-in, fade-out and changes in density, the quality drops significantly. Ironically, the background is also affected: It should actually be a flat gray tone, but youtube somehow (temporarily) introduces a vertical color gradient with visible steps. While the raw video (before upload) is - as expected - virtually perfect, it comes with its own set of issues: The above example requires 523 MByte of space for 10 seconds at 60 fps 1920x1080 px and barely plays on VLC. Longer videos of this kind are therefore problematic.
I have to admit that I am new to this field: Where do I start reading? How do I optimize the output of ffmpeg for this kind of content for the intended purpose?
do i get you wrong about you want a lossless compression?
https://trac.ffmpeg.org/wiki/Encode/H.264

Choose a CRF value
The range of the CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28. Consider 17 or 18 to be visually lossless or nearly so ...

or
https://trac.ffmpeg.org/wiki/Encode/FFV1
FFV1 is a video codec developed within FFmpeg. It is lossless, meaning that it compresses video without introducing quantization degradations.
or
you can google lossless compression