Body: <p>Setting <code>-pix_fmt</code> to a yuv colorspace will use Bayer dithering by default. I don't know how to change that behaviour.</p>
  <p>When downsampling with <code>-pix_fmt</code> to an RGB colorspace like rgb24, no dithering is applied, resulting in ugly banding.</p>
  <p>Edit:</p>
  <p>I figured out how to control dithering to YUV colorspace. My issue was just that I misunderstood the ffmpeg filter syntax regarding <code>format</code>. It's not handled as a filter, but just tells the preceding filter what format to output:</p>
  <pre><code>-vf zscale:r=tv:d=error_diffusion,format=yuv420p
  </code></pre>
  <p>The issue is, zscale seems to be unable to dither at all when downsampling to RGB colorspace. 4 bpc RGB seems to be the exception, where ordered dithering is enforced. And I am unable to control dithering with the scale/swscale filter at all, using a global flag <code>-sws_dither ed</code> does not work.</p>
  <p><code>colorspace</code> filter can not output to RGB format.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-13T04:32:39.433Z
Comments.Text: Share full command and log.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-13T12:23:56.960Z
Comments.Text: @Gyan full command: `ffmpeg -i <infile> -pix_fmt bgr0 -vcodec ffv1 -level 3 -threads 16 -coder 1 -context 1 -slices 24 -slicecrc 1 <outfile> `
  Whether the input file is 10-bit YUV or 10-bit RGB does not matter, dithering is never applied when downsampling to an RGB colorspace.
Comments.UserDisplayName: damian101
Tags: <ffmpeg>
Title: How can I downsample video to rgb24 with dithering in ffmpeg?
UserDisplayName: damian101
ThreadText: # How can I downsample video to rgb24 with dithering in ffmpeg?
  
  (Asked by: username_0 on 2021-11-12)
  
  Setting `-pix_fmt` to a yuv colorspace will use Bayer dithering by default. I don't know how to change that behaviour.
  
  When downsampling with `-pix_fmt` to an RGB colorspace like rgb24, no dithering is applied, resulting in ugly banding.
  
  Edit:
  
  I figured out how to control dithering to YUV colorspace. My issue was just that I misunderstood the ffmpeg filter syntax regarding `format`. It's not handled as a filter, but just tells the preceding filter what format to output:
  
  ```
  -vf zscale:r=tv:d=error_diffusion,format=yuv420p
  
  ```
  
  The issue is, zscale seems to be unable to dither at all when downsampling to RGB colorspace. 4 bpc RGB seems to be the exception, where ordered dithering is enforced. And I am unable to control dithering with the scale/swscale filter at all, using a global flag `-sws_dither ed` does not work.
  
  `colorspace` filter can not output to RGB format.
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Share full command and log.  
  > **username_0**: @username_1 full command: `ffmpeg -i <infile> -pix_fmt bgr0 -vcodec ffv1 -level 3 -threads 16 -coder 1 -context 1 -slices 24 -slicecrc 1 <outfile> ` Whether the input file is 10-bit YUV or 10-bit RGB does not matter, dithering is never applied when downsampling to an RGB colorspace.  
  
  ---
  
  ## 0 answers
  
  