How to Use the FFmpeg unpremultiply Filter
This guide explains how to reverse alpha channel premultiplication in
video and image assets using FFmpeg's unpremultiply video
filter. You will learn the mechanics of premultiplied versus straight
alpha, the primary syntax of the unpremultiply filter, its
configurable parameters, and practical command-line examples to restore
correct color representation in your media workflows.
Understanding Premultiplication
In computer graphics, a premultiplied alpha image has its color channels (Red, Green, and Blue) already multiplied by its transparency channel (Alpha):
\[\text{Color}_{\text{premultiplied}} = \text{Color}_{\text{original}} \times \text{Alpha}\]
While useful for real-time rendering, premultiplied assets can cause
dark fringes, halos, or blending artifacts if imported into software
expecting "straight" (unassociated) alpha. The
unpremultiply filter reverses this process by dividing the
color channels by the alpha values:
\[\text{Color}_{\text{original}} = \frac{\text{Color}_{\text{premultiplied}}}{\text{Alpha}}\]
Basic Syntax
To use the filter, ensure your input file contains an alpha channel
(such as formats using rgba, yuva420p, or
yuva444p10le pixel formats).
The basic filter call is:
ffmpeg -i input.mov -vf "unpremultiply" output.movFilter Options
The unpremultiply filter accepts two primary
parameters:
planes: A bitmask specifying which planes to process.1: 1st plane (e.g., Red or Y)2: 2nd plane (e.g., Green or U)4: 3rd plane (e.g., Blue or V)8: 4th plane (Alpha)- Default is
15(all planes: \(1 + 2 + 4 + 8\)). To only unpremultiply the color channels and leave the alpha channel intact, you can set this to7(\(1 + 2 + 4\)).
inplace: Determines whether the operation processes the frame directly in memory.0: Disabled (default).1: Enabled. Can improve performance and reduce memory usage in complex filtergraphs.
Practical Examples
1. Converting a Premultiplied PNG to Straight Alpha
To convert a single image with premultiplied alpha back to straight alpha:
ffmpeg -i input_premultiplied.png -vf "unpremultiply=planes=7" output_straight.png2. Processing ProRes 4444 Video
ProRes 4444 files with alpha often carry premultiplied color channels from compositing software. To convert the stream to straight alpha while maintaining high quality:
ffmpeg -i input_premult.mov -vf "unpremultiply" -c:v prores_ks -profile:v 4444 -pix_fmt yuva444p10le output_straight.mov3. Converting Premultiplied Video to Transparent WebM
When preparing assets for the web (such as VP9 WebM with transparency), browsers typically expect straight alpha:
ffmpeg -i input_premult.mov -vf "unpremultiply" -c:v libvpx-vp9 -pix_fmt yuva420p -b:v 2M output.webmVerification
If the colors of semi-transparent edges appear overly bright or
saturated after applying the filter when viewed against a black
background, the input was likely straight alpha already. Apply
unpremultiply only to files specifically exported with
premultiplied (associated) alpha channels.