Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Notes

The big issue here is that by default if you start converting images to another format, and ffmpeg cannot determine the colorspace  it will default to bt601. So many of the flags below are to:

A: Tell ffmpeg that the source media is in fact bt709

B: Add the metadata to the output, so that other future conversions also know how to convert it back.

C: Do as clean a conversion from RGB to YUV as possible.

Example Usages


NameSourceffmpeg flags

Description

ffmpeg colormatrixhttps://trac.ffmpeg.org/wiki/colorspace
-pix_fmt yuv444p10le -sws_flags spline+accurate_rnd+full_chroma_int -vf "colormatrix=bt470bg:bt709" -color_range 1 -colorspace 1 -color_primaries 1 -color_trc 1
8bpc only

The sws_flags are needed for the RGB to YUV conversion.

-color_range 1   # mpeg see: FFmpeg/pixfmt.h at master · FFmpeg/FFmpeg · GitHub

-colorspace 1 # BT709   FFmpeg/pixfmt.h at master · FFmpeg/FFmpeg · GitHub

-color_primaries 1 # BT709 FFmpeg/pixfmt.h at master · FFmpeg/FFmpeg · GitHub

-color_trc 1 # bt709 FFmpeg/pixfmt.h at master · FFmpeg/FFmpeg · GitHub - Color Transfer Characteristics.

ffmpeg colorspacehttps://trac.ffmpeg.org/wiki/colorspace
-pix_fmt yuv444p10le -sws_flags spline+accurate_rnd+full_chroma_int -vf "colorspace=bt709:iall=bt601-6-625:fast=1" -color_range 1 -colorspace 1 -color_primaries 1 -color_trc 1 
Supports 10bpc and 12bpc, SIMD (faster), better quality than colormatrix.

...

NameSourceffmpeg flagsDescriptionSize
colorspace_yuv444p10lehttps://trac.ffmpeg.org/wiki/colorspace-c:v libx264 -preset placebo -qp 0 -x264-params "keyint=15:no-deblock=1" -pix_fmt yuv444p10le -sws_flags spline+accurate_rnd+full_chroma_int -vf "colorspace=bt709:iall=bt601-6-625:fast=1" -color_range 1 -colorspace 1 -color_primaries 1 -color_trc 1

Prores 4444
-c:v prores_ks -profile:v 4444 -qscale:v 1 -pix_fmt yuv444p10le -sws_flags spline+accurate_rnd+full_chroma_int -vf "colorspace=bt709:iall=bt601-6-625:fast=1" -color_range 1 -colorspace 1 -color_primaries 1 -color_trc 1

shotgun_diy_encodehttps://support.shotgunsoftware.com/hc/en-us/articles/219030418-Do-it-yourself-DIY-transcoding',-vcodec libx264 -pix_fmt yuv420p -g 30 -vprofile high -bf 0 -crf 2