How to tell whether the colors in a video frame decoded by FFmpeg are pre-multiplied by alpha?
Asked Answered
P

2

6

When I decode video frames with FFmpeg (avcodec_decode_video2(), sws_scale()), with some videos (e.g., ProRes4444), I get colors pre-multiplied by alpha, and with other videos (e.g., QuickTime PNG), I get colors that aren't pre-multiplied by alpha.

How can I tell whether the colors are pre-multiplied? Alternatively, how can I tell FFmpeg to always provide either pre-multiplied or un-pre-multiplied ("straight alpha") colors?

Pectoralis answered 23/11, 2013 at 5:44 Comment(1)
Good question! Ever found out the answer?Burley
H
0

Try looking at AVCodecContext's color-space related properties, like AVColorSpace.

Halstead answered 11/12, 2013 at 0:56 Comment(1)
Thanks. I checked AVCodecContext's colorspace, color_range, and color_trc values, but they're identical in the pre-multiplied and un-pre-multiplied movies I've tested.Pectoralis
D
0

The alpha is always straight, never pre-multiplied.

ffmpeg doc writes. https://ffmpeg.org/doxygen/4.1/pixdesc_8h.html#a06924ef0ebf07d8742ff8994e3a948bf

Deviate answered 28/5, 2024 at 12:26 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.