(FFmpeg) How To Generate A Color Palette From A Video And Apply ...

John Riselvato I ponder more than I author Skip to content

(FFmpeg) How to Generate a Color Palette From a Video and apply it to another?

Ever look at a video with an amazing color grading and wish you could copy it? Getting that look can be accomplished using the palettegen filter. palettegen generates a single palette for an entire video stream and saves it as an image file.

Figure 64.0: color palette for input.mp4 (enlarged)

 In this example, a color palette of 256 pixels is generated, as seen in figure 64.0:

$ ffmpeg -i input.mp4 -vf "palettegen" palette.png

a 256 pixel palette.png was generated from input.mp4. In this example, the same palette.png is applied to input2.mp4 giving it the same color palette input.mp4 had.

Figure 65.0: the input.mp4 color palette applied to input2.mp4

The difference is subtle yet very aesthetically pleasing. The new palette applies faded blue color where green was once seen, as seen in figure 65.0:

$ ffmpeg -i input2.mp4 -i palette.png -filter_complex "paletteuse" -c:v libx264 -pix_fmt yuv420p output.mp4

Variables:

paletteuse Indicates the palette use filter name dither Indicates the selected dithering mode (default is sierra2_4a) bayer Ordered 8x8 bayer dithering heckbert Paul Heckbert's simple error diffusion floyd_steinberg Floyd and Steingberg dithering sierra2 Frankie Sierra dithering v2 sierra2_4a Frankie Sierra dithering v2 "Lite"

For more information on the advanced parameters available for paletteuse, visit: https://ffmpeg.org/ffmpeg-filters.html#paletteuse

Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!

buy now on amazon
Comments closed Trackbacks closed RSS 2.0 feed for these comments This entry (permalink) was posted on Thursday, May 21, 2020, at 2:21 pm by jdriselvato. Filed in Tutorial, Programming and tagged FFmpeg. « (FFmpeg) How to Remove All Colors Except One From a Video? Installing Katago in Sabaki 2 for MacOS (2021) » Home
  • Projects

    Pen Pinery MTHU Database Visual Signals Zine Github
  • Recent Posts

    • AETAS//ONE December 4, 2024
    • The Pre-Raphaelite Brotherhood, Ophelia, and Life January 12, 2022
    • ‘A Book of Visual Signalwave’ my first independent success March 13, 2020
    • Hit 250 followers on twitter with 31 episodes April 11, 2019
    • WordPress Meet up in Raleigh for help? April 6, 2019
  • Categories

    • Blogging
    • Music
    • Programming
    • Science
    • Tutorial
    • Uncategorized
  • Tags

    FFmpeg

  • Archives

    • December 2024
    • January 2022
    • December 2021
    • May 2020
    • April 2020
    • March 2020
    • April 2019
    • December 2017
    • July 2016
    • March 2016
    • February 2016
    • September 2015
    • May 2015
    • June 2014
    • May 2014
    • February 2014
    • January 2014
    • December 2013
    • October 2013
    • September 2013
    • July 2013
    • June 2013
    • April 2013
    • March 2013
    • February 2013
© 2025 | Powered by WordPress | plaintxtblog theme by PlainTXT.org | Valid XHTML & CSS | Posts RSS & Comments RSS

Tag » Color Palette Ffmpeg