user2995705
user2995705

Reputation: 27

generate transparent video overlay or another way?

my src files are lots of pngs, and b.mp4

What i want : overlay pngs (as anim) on b.mp4

the way i have tried: the size of 200 pngs are almost 40M,could not put into the android phone.. so I generate pngs to transparent video use this command: "ffmpeg -i %04d.png -vcodec png a.mov "

then use "ffmpeg -i b.mp4 -i a.mov -vf overlay=0:0:0 out.mp4", it worked. but the problem I got is that the size of a.mov is too big (200 pngs,each file is 100k, a.mov is about 100M ),and i tried -vcodec copy,rawvideo,qtle,also got a very big file. are there any idea to resolve this problem?

then I tried to find another way:I generate pngs to mp4,use

ffmpeg -i %04d.png -vcodec libx264 a.mp4

and I know libx264 with yuv420p(libx264 not support yuva420p) could not keep the alpha channel? but I still want to have a try.then I overlay a.mp4 on b.mov;

obviously,a black background under a.mp4 ....because it lost it's alpha channel? then I tried blend filter, I find blend=all_mode=lighten looks a bit same as what i want?but it's still not as same as the effect (overlay)

any one who can help me ,thanks

Upvotes: 1

Views: 828

Answers (1)

Cy Scott
Cy Scott

Reputation: 66

You can overlay the png files directly over the video in one command. For example:

ffmpeg -i b.mp4 -framerate 30 -i %04d.png -filter_complex [0:v][1:v]overlay=format=yuv420[vid] -map [vid] -r 30 output.mp4

In the past, I've found that png files are better for overlays then a mov file. Make sure that you provide the frame rate for the png input, otherwise it will assume 25 fps (which may not be the same fps as video b.mp4).

Upvotes: 1

Related Questions