I'm trying to take 3 PNG images with transparent background and make a crossfade video with them so I can then put that video on to a background video. I understand I can do possibly do this in 1 command but would like to keep it separate as the background video may be interchangeable. What I have so far is;

ffmpeg -loop 1 -t 1 -i 1.png -loop 1 -t 1 -i 2.png -loop 1 -t 1 -i 3.png -
filter_complex "[1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-
(if(gte(T,0.5),1,T/0.5)))'[b1v]; [2:v][1:v]blend=all_expr='A*
(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v]; [0:v][b1v][1:v]
[b2v][2:v]concat=n=5:v=1:a=0,format=yuv420p[v]" -map "[v]" out.mp4

This seems to work but the background is now black not transparent, I have tried making the output different file types (avi, mov etc.) but that has no effect. The next command I am running is;

ffmpeg -i out.mp4 -i video.mp4 -filter_complex "[0:v]scale=1080:-2[fg1]; 
[fg1]overlay=400:400:shortest=1,format=yuv420p[v]" -map "[v]" -movflags 
+faststart final.mp4

This also seems to work but again the video I am overlaying doesn't have the transparency so looks bad. Is there a way I can make the first video honour the transparency from the original pngs? If it requires a single command I am happy to do that but I've hit a wall at this point. Any help is appreciated.


In the first command, change format=yuv420p to format=yuva420p. Transparency requires an alpha channel but you are, at, present, converting to a format without one. format=yuva444p will provide a slightly better quality.

And more importantly, output to -map "[v]" -c:v png out.mov

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.