Rodrigo Polo
Rodrigo Polo

Reputation: 4774

FFmpeg: Add alpha channel to a video using a PNG mask

I saw that FFmpeg can merge/blend two videos with alpha channel and can encode video with alpha channel using the qtrle codec, but, It is possible to apply a PNG file mask, either a black and white or a PNG with an alpha channel to a video in order to have a video with the alpha channel of the PNG applied?

Here is the concept in images

Original video: Original video

PNG file with alpha channel, the "mask": PNG file with alpha channel

And the result: Result

Or even a black and white image as a mask for alpha channel: bnw image

Any help would be appreciated, thank you!

Upvotes: 8

Views: 17995

Answers (1)

Gyan
Gyan

Reputation: 93068

Use the alphaextract and alphamerge filters:

ffmpeg -i video -vf "movie='image',alphaextract[a];[in][a]alphamerge" -c:v qtrle output.mov

Upvotes: 7

Related Questions