Itemlume
Sign inCreate account

PRODUCT CREATIVE / PRODUCTION AND HANDOFF

How Can FFmpeg Preserve Product Colors Across a GIF?

Generate and evaluate the palette against the intended animation, not just its opening frame. FFmpeg's palettegen defaults to full-frame histogram analysis across the stream, while other statistics modes prioritize changed regions or individual frames. Palette selection and dithering both affect the delivered GIF.

01 / HOW CAN FFMPEG PRESERVE PRODUCT COLORS ACROSS A GIF?

Choose the Intended Histogram Scope

palettegen builds a palette from a histogram: a count of colors encountered in the analyzed image content. Its default stats_mode=full accumulates statistics from complete frames across the stream, so colors appearing near the ending can participate in the same palette budget.

stats_mode=diff counts only portions that differ from the previous frame. It can give moving content greater weight than an unchanged background. Neither full nor diff guarantees a particular brand-color match.

stats_mode=single creates a new histogram for every frame. That is a per-frame palette strategy, not a drop-in substitute for one whole-stream palette. paletteuse's corresponding new option takes a new palette for each output frame; such a workflow must keep the video frames and their palettes correctly paired.

For the single-palette workflow discussed here, generate the palette from the complete intended input, then apply that palette to the same input. The following two commands adapt the official documentation examples and have not been executed for this article.

Unexecuted documentation example, stage 1: ffmpeg -i input.mkv -vf palettegen review-palette.png

Unexecuted documentation example, stage 2: ffmpeg -i input.mkv -i review-palette.png -lavfi paletteuse review.gif

The FFmpeg palettegen reference defines whole-stream, changed-region and per-frame histogram modes.

The FFmpeg paletteuse reference documents applying the palette and the per-frame new option.

02 / HOW CAN FFMPEG PRESERVE PRODUCT COLORS ACROSS A GIF?

Understand the Actual Palette Budget

The max_colors setting limits the number of quantized colors, but the generated palette still contains 256 entries. Unused entries are black.

By default, reserve_transparent is enabled, reserving the final palette entry for transparency. This leaves a maximum of 255 actual colors.

The paletteuse filter accepts the video and a palette image containing 256 pixels. Those pixels do not necessarily represent 256 distinct colors.

Quantization maps a larger set of input colors to the smaller output palette. palettegen reports lavfi.color_quant_ratio as nb_color_in / nb_color_out: the input-color count divided by the output-color count. This describes color reduction, not perceptual error or a measured brand-color match.

Decision branch: Check the color budget and transparency reservation before interpreting missing shades as a source-image defect.

03 / HOW CAN FFMPEG PRESERVE PRODUCT COLORS ACROSS A GIF?

Evaluate Dithering and Changed Regions

paletteuse defaults to sierra2_4a dithering. Other documented choices include none and bayer, with different visual trade-offs.

Dithering can approximate unavailable colors through pixel patterns, but it may also introduce visible texture or moving noise.

The rectangle diff_mode restricts processing to the changed rectangle and may reduce moving noise in suitable animations. It does not guarantee accurate reproduction of every product color.

Decision branch: If static regions appear unnecessarily active, evaluate changed-rectangle processing. If fine patterns distract from product details, compare dithering choices rather than assuming the default is universally preferable.

04 / HOW CAN FFMPEG PRESERVE PRODUCT COLORS ACROSS A GIF?

Illustrative Exercise: Two Animation Inputs

Illustrative exercise — fictional product animations, not executed GIF encoding or ImageMagick tests. Input A shows a moving product over a mostly static background; Input B introduces an important brand color on its closing card.

For A, plan a full-versus-diff comparison while keeping the source, color budget and paletteuse settings fixed. Inspect product detail and background texture separately. For B, include the complete ending in palette generation and inspect its delivered color rather than approving from the opening frame.

After any real encoding, record the actual palette and dithering settings, then inspect opening, middle and ending frames at the intended display size. Record observed color shifts, banding or moving noise instead of treating the settings as a successful result.

For the delivery-format decision, the email GIF, video and static-fallback guide compares a separate set of channel constraints.

05 / HOW CAN FFMPEG PRESERVE PRODUCT COLORS ACROSS A GIF?

GIF Palette Review — Complete After Actual Encoding

These are illustrative exercise rows. Save a copy and record your own observations; the example is not an executed acceptance test.

Review caseInput and histogram scopePalette budgetpaletteuse settingsObserved outputDelivery decision
A: Moving product, static background[Fill: file/version; full or diff][Fill: max_colors; reserve_transparent][Fill: dither; diff_mode][Fill: opening/middle/ending product detail, background noise and display size][Fill after review: accept, adjust or change format, with reason]
B: Late brand-color card[Fill: file/version and complete analyzed duration][Fill: palette budget and any recorded color_quant_ratio][Fill: actual settings][Fill: observed end-card color/banding against approved reference][Fill after review: result and remaining discrepancy]

Download review worksheet (CSV)

Published by ItemlumePublished Updated Evidence and editorial policy
SOURCES & SCOPE

Sources and further reading

Recorded source-review dates are listed individually below. An undated source does not inherit the article’s publication date. Software and platform rules can change; check the current original before acting.

QUESTIONS, ANSWERED

Frequently asked questions

Does max_colors=64 create a palette image containing only 64 pixels?

No. The palette still contains 256 entries, with unused entries black. The setting limits the quantized color count.

Will a global palette always preserve every brand color perfectly?

No. A global palette allocates a limited color budget across the animation. Review the actual opening, middle, and ending frames rather than relying on palette statistics alone.

Can I switch the two-stage whole-stream example to stats_mode=single without changing anything else?

No. single creates a histogram for each frame. A per-frame palette workflow also needs corresponding paletteuse behavior and correct frame-to-palette pairing; it is a different strategy from the one-palette example.

PREPARE ASSETS FOR YOUR NEXT STEP

Create supporting product assets in Itemlume.

Create new product creative assets in the workspace, then continue in your chosen tools. Third-party software procedures described in this guide take place in those applications; this workspace link does not imply an integration. Check current capabilities, account access and credit quotes.

Explore asset creation tools Check pricing and credits