Answers.Body: <p>do i get you wrong about you want a lossless compression?</p>
  <p><a href="https://trac.ffmpeg.org/wiki/Encode/H.264" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/Encode/H.264</a></p>
  <ol>
  <li>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 ...</li>
  </ol>
  <p>or</p>
  <p><a href="https://trac.ffmpeg.org/wiki/Encode/FFV1" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/Encode/FFV1</a></p>
  <p>FFV1 is a video codec developed within FFmpeg. It is lossless, meaning that it compresses video without introducing quantization degradations.</p>
  <p>or</p>
  <p>you can google lossless compression</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-04T09:20:54.293Z
Answers.Text: It does not have to be lossless. I want to "optimize" the *kind of compression artifacts* that I get on Youtube. I'd like to "force the compression into the right direction", if this makes any sense, by "playing" with the compression of the uploaded video.
Answers.UserDisplayName: s-m-e
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-03T11:22:53.037Z
Answers.LastActivityDate: 2020-09-03T11:22:53.037Z
Answers.UserDisplayName: xer-rex
Body: <p>Based on <a href="https://video.stackexchange.com/q/30077/29532">this older question</a>, 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.</p>
  <p>I built a small <a href="https://github.com/pleiszenburg/bewegung" rel="nofollow noreferrer">Python framework called &quot;bewegung&quot;</a> around <code>ffmpeg</code> and a bunch of Python visualization libraries for animating scientific data. I am calling <code>ffmpeg</code> as follows, writing BMPs directly to stdin:</p>
  <pre class="lang-python prettyprint-override"><code>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,)
  </code></pre>
  <p>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.</p>
  <p>For content based on a few lines and polygons, this works just fine.</p>
  <p><a href="https://www.youtube.com/watch?v=5KldBStctRU" rel="nofollow noreferrer"><img src="https://i3.ytimg.com/vi/5KldBStctRU/hqdefault.jpg" alt="good example" /></a></p>
  <p>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:</p>
  <p><a href="https://www.youtube.com/watch?v=FXo9f_6SbDs" rel="nofollow noreferrer"><img src="https://i3.ytimg.com/vi/FXo9f_6SbDs/hqdefault.jpg" alt="bad example" /></a></p>
  <p>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.</p>
  <p>I have to admit that I am new to this field: Where do I start reading? How do I optimize the output of <code>ffmpeg</code> for this kind of content for the intended purpose?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-03T08:29:59.887Z
Comments.Text: Try Vimeo. Both sites will always transcode user submissions, the file you upload is not what the viewer is served. But Vimeo applies less compression. You're likely to be disappointed if you expect close to perfect fidelity with fine textures.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-03T08:43:21.577Z
Comments.Text: @Gyan I know that I can not expect perfection. My problem is more like: I have seen better (on Youtube). So I *think* that there is still room for improvement ...
Comments.UserDisplayName: s-m-e
Tags: <ffmpeg><video-quality><animation><animation-rendering>
Title: Optimizing ffmpeg settings for high-entropy / HIGH-DETAIL ANIMATIONS towards uploading to youtube
UserDisplayName: s-m-e
ThreadText: # Optimizing ffmpeg settings for high-entropy / HIGH-DETAIL ANIMATIONS towards uploading to youtube
  
  (Asked by: username_0 on 2020-09-02)
  
  Based on [this older question](https://video.stackexchange.com/q/30077/29532), I am looking for a good "transfer video codec / compression" 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 "bewegung"](https://github.com/pleiszenburg/bewegung) around `ffmpeg` and a bunch of Python visualization libraries for animating scientific data. I am calling `ffmpeg` as follows, writing BMPs directly to stdin:
  
  ```python
  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.
  
  [![good example](https://i3.ytimg.com/vi/5KldBStctRU/hqdefault.jpg)](https://www.youtube.com/watch?v=5KldBStctRU)
  
  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:
  
  [![bad example](https://i3.ytimg.com/vi/FXo9f_6SbDs/hqdefault.jpg)](https://www.youtube.com/watch?v=FXo9f_6SbDs)
  
  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?
  
  **Tags:** ffmpeg, video-quality, animation, animation-rendering
  
  > **Comments:**
  > **username_1**: Try Vimeo. Both sites will always transcode user submissions, the file you upload is not what the viewer is served. But Vimeo applies less compression. You're likely to be disappointed if you expect close to perfect fidelity with fine textures.  
  > **username_0**: @username_1 I know that I can not expect perfection. My problem is more like: I have seen better (on Youtube). So I *think* that there is still room for improvement ...  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-09-03. Score: 1
  
  do i get you wrong about you want a lossless compression?
  
  <https://trac.ffmpeg.org/wiki/Encode/H.264>
  
  1. 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
  
  > **Comments:**
  > **username_0**: It does not have to be lossless. I want to "optimize" the *kind of compression artifacts* that I get on Youtube. I'd like to "force the compression into the right direction", if this makes any sense, by "playing" with the compression of the uploaded video.  
  
  ---
  
  