how to fade two images with ffmpeg

2020-03-06 02:44发布

I have two images and I want to create a simple fading transition between them.

I also want the final output to be a sequence of images rather than a video? So if the fading transition was 10 frames long I'd want the output to be a sequence of 10 images.

How can I achieve this with ffmpeg?

3条回答
霸刀☆藐视天下
2楼-- · 2020-03-06 02:55

See the blend video filter:

ffmpeg -loop 1 -i input0.png -loop 1 -i input1.png -filter_complex "[1:v][0:v]blend=all_expr='A*(if(gte(T,3),1,T/3))+B*(1-(if(gte(T,3),1,T/3)))'" -t 4 frames_%04d.png

This example will make a 3 second cross-fade of input1.png over input0.png.

To crossfade/dip-to-black multiple images see Create video with 5 images with fade-in/out effect in ffmpeg.

查看更多
爷的心禁止访问
3楼-- · 2020-03-06 03:00

To the best of my knowledge you cannot achieve this just with ffmpeg. Please take a look at MLT framework if you want to do it in scriprs; take a look at openshot if you want an interactive app.

查看更多
时光不老,我们不散
4楼-- · 2020-03-06 03:08

Try this:

ffmpeg \
-loop 1 -t 3 -i input1.png \
-loop 1 -t 3 -i input2.png \
-loop 1 -t 3 -i input3.png \
-loop 1 -t 3 -i input4.png \
-loop 1 -t 3 -i input5.png \
-filter_complex \
"[1:v][0:v]blend=all_expr='A*(if(gte(T,3),1,T/3))+B*(1-(if(gte(T,3),1,T/3)))'[v0]; \
 [2:v][1:v]blend=all_expr='A*(if(gte(T,3),1,T/3))+B*(1-(if(gte(T,3),1,T/3)))'[v1]; \
 [3:v][2:v]blend=all_expr='A*(if(gte(T,3),1,T/3))+B*(1-(if(gte(T,3),1,T/3)))'[v2]; \
 [4:v][3:v]blend=all_expr='A*(if(gte(T,3),1,T/3))+B*(1-(if(gte(T,3),1,T/3)))'[v3]; \
 [v0][v1][v2][v3]concat=n=4:v=1:a=0[v]"
-map "[v]" out.mp4

Haven't tried with images, but you could try -t 12 frames_%04d.png at the end or whatever.

查看更多
登录 后发表回答