<p>I am trying to making a video using 1 background image and 5 transparent images (all the images are in same dimensions 500x500). Where the 5 transparent images animate for 2 seconds (Slideup, WipeDown, Fade etc.) and come to their original positions using Xfade and FFMpeg.</p>
<p><a href="https://i.sstatic.net/e43aB.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/e43aB.jpg" alt="Final Video Image" /></a></p>
<p>When I tried the example in the Xfade site using 3 images (1 background image and two transparent images), the first image i.e. 1.png is overlaid on the background image i.e. bg.jpg and after 4 seconds next the second image i.e. 2.png moved from right to left, I got the transition what I expected but the 2.png is overlapping the 1.png, where I want to show the 1.png also. Below is the example I tried.</p>
<p><code>ffmpeg -loop 1 -t 5 -i bg.jpg -loop 1 -t 5 -i 1.png -loop 1 -t 5 -i 2.png -filter_complex &quot;[1][2]xfade=transition=wipeleft:duration=1:offset=4,format=yuva420p[trans];[0][trans]overlay=10:10&quot; -c:v libx264 -preset ultrafast -tune stillimage -c:a aac -strict experimental -b:a 192k output3.mp4</code></p>
<p>All I want to animate the 5 images on a background image, each image should come one after the other with 2 seconds transitions and all the 5 transparent images should overlay on the background image and all the images should be visible. Over all the video should be of 20 seconds length.</p>
<p>Note: all the images are in same dimensions 500x500, I attached all the images below.</p>
<p>Thank you.</p>
<p><a href="https://i.sstatic.net/90P7t.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/90P7t.jpg" alt="Background Image" /></a></p>
<p><a href="https://i.sstatic.net/FhjCg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FhjCg.png" alt="1.png" /></a></p>
<p><a href="https://i.sstatic.net/idXsz.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/idXsz.png" alt="2.png" /></a></p>
<p><a href="https://i.sstatic.net/DSqUr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/DSqUr.png" alt="3.png" /></a></p>
<p><a href="https://i.sstatic.net/L96ad.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/L96ad.png" alt="4.png" /></a></p>
<p><a href="https://i.sstatic.net/UETTs.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UETTs.png" alt="5.png" /></a></p>
<p><a href="https://i.sstatic.net/OtlcV.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OtlcV.jpg" alt="Final Video should be like this" /></a></p>

CC BY-SA 4.0
2023-11-27T05:49:19.100Z
add blank video: `-filter_complex "
color=black@0:s=500x500[t1];
[t1][1]xfade=transition=wipeleft:duration=1:offset=2[t1];
[0][t1]overlay=10:10[o1];

color=black@0:s=500x500[t2];
[t2][2]xfade=transition=wipedown:duration=1:offset=2[t2];
[o1][t2]overlay=10:10...`
Баяр Гончикжапов
CC BY-SA 4.0
2023-11-27T18:52:17.770Z
@БаярГончикжапов Hi, thank you for the answer... i got the output what i am looking for...
i have few doubts...
1.How to set the duration of the video to fixed time Ex: 30 seconds duration
2. How to add a song to this (here if the song duration is 40 sec i.e, greater than the fixed duration then final video duration should be 40 secs)
3. How to control the animation to get smooth transition effects...

Thank you.
RSD
CC BY-SA 4.0
2023-11-28T07:49:00.080Z
1. `...-t 30 -i bg.jpg...` 2. `... -shortest output.mp4`
Баяр Гончикжапов
CC BY-SA 4.0
2023-11-28T17:49:58.150Z
@БаярГончикжапов How to add the song? i added -i audio.mp3 but it doesn't work...
RSD
CC BY-SA 4.0
2023-11-29T04:16:56.660Z
`ffmpeg -loop 1 -i bg.jpg ....png -t 40 -i audio.mp3 -filter_complex ... -shortest out.mp4`
Баяр Гончикжапов
CC BY-SA 4.0
2023-11-29T14:25:16.937Z
@БаярГончикжапов Thank you.
RSD
<ffmpeg><animation>
How to animate transparent images using Xfade and ffmpeg
RSD
# How to animate transparent images using Xfade and ffmpeg

(Asked by: username_0 on 2023-11-26)

I am trying to making a video using 1 background image and 5 transparent images (all the images are in same dimensions 500x500). Where the 5 transparent images animate for 2 seconds (Slideup, WipeDown, Fade etc.) and come to their original positions using Xfade and FFMpeg.

[![Final Video Image](https://i.sstatic.net/e43aB.jpg)](https://i.sstatic.net/e43aB.jpg)

When I tried the example in the Xfade site using 3 images (1 background image and two transparent images), the first image i.e. 1.png is overlaid on the background image i.e. bg.jpg and after 4 seconds next the second image i.e. 2.png moved from right to left, I got the transition what I expected but the 2.png is overlapping the 1.png, where I want to show the 1.png also. Below is the example I tried.

`ffmpeg -loop 1 -t 5 -i bg.jpg -loop 1 -t 5 -i 1.png -loop 1 -t 5 -i 2.png -filter_complex "[1][2]xfade=transition=wipeleft:duration=1:offset=4,format=yuva420p[trans];[0][trans]overlay=10:10" -c:v libx264 -preset ultrafast -tune stillimage -c:a aac -strict experimental -b:a 192k output3.mp4`

All I want to animate the 5 images on a background image, each image should come one after the other with 2 seconds transitions and all the 5 transparent images should overlay on the background image and all the images should be visible. Over all the video should be of 20 seconds length.

Note: all the images are in same dimensions 500x500, I attached all the images below.

Thank you.

[![Background Image](https://i.sstatic.net/90P7t.jpg)](https://i.sstatic.net/90P7t.jpg)

[![1.png](https://i.sstatic.net/FhjCg.png)](https://i.sstatic.net/FhjCg.png)

[![2.png](https://i.sstatic.net/idXsz.png)](https://i.sstatic.net/idXsz.png)

[![3.png](https://i.sstatic.net/DSqUr.png)](https://i.sstatic.net/DSqUr.png)

[![4.png](https://i.sstatic.net/L96ad.png)](https://i.sstatic.net/L96ad.png)

[![5.png](https://i.sstatic.net/UETTs.png)](https://i.sstatic.net/UETTs.png)

[![Final Video should be like this](https://i.sstatic.net/OtlcV.jpg)](https://i.sstatic.net/OtlcV.jpg)

**Tags:** ffmpeg, animation

> **Comments:**
> **username_1**: add blank video: `-filter_complex " color=black@0:s=500x500[t1]; [t1][1]xfade=transition=wipeleft:duration=1:offset=2[t1]; [0][t1]overlay=10:10[o1];  color=black@0:s=500x500[t2]; [t2][2]xfade=transition=wipedown:duration=1:offset=2[t2]; [o1][t2]overlay=10:10...`  
> **username_0**: @БаярГончикжапов Hi, thank you for the answer... i got the output what i am looking for... i have few doubts... 1.How to set the duration of the video to fixed time Ex: 30 seconds duration 2. How to add a song to this (here if the song duration is 40 sec i.e, greater than the fixed duration then final video duration should be 40 secs) 3. How to control the animation to get smooth transition effects...  Thank you.  
> **username_1**: 1. `...-t 30 -i bg.jpg...` 2. `... -shortest output.mp4`  
> **username_0**: @БаярГончикжапов How to add the song? i added -i audio.mp3 but it doesn't work...  
> **username_1**: `ffmpeg -loop 1 -i bg.jpg ....png -t 40 -i audio.mp3 -filter_complex ... -shortest out.mp4`  
> **username_0**: @БаярГончикжапов Thank you.  

---

## 0 answers

