dreamfire
dreamfire

Reputation: 427

Extract alpha from video ffmpeg

I want to overlay transparent video on the background image. I have a video where the top half is RGB object and bottom half is an alpha mask.

Now, for making this I do next steps:

1) I am extracting all frames from video and save to the folder

2) Each frame splitting to top and bottom half bitmap

3) Top bitmap composite with bottom mask for extract alpha and get a frame with transparent background

3) I am drawing each frame on the background and save to a folder

4) Create a video using FFmpeg

The problem is step 2, 3 and 4, they very slow. Maybe has another way to overlay transparent video on the background image?

Upvotes: 2

Views: 1045

Answers (1)

Gyan
Gyan

Reputation: 93379

You can use

ffmpeg -i bg -i video_with_mask
       -filter_complex "[1]crop=iw:ih/2:0:0[rgb];[1]crop=iw:ih/2:0:ih/2[alp];\
                        [rgb][alp]alphamerge[va];[0][va]overlay"  out 

Upvotes: 3

Related Questions