Transitions : fade-in & fade-out - 2020
bogotobogo.com site search:
fade-in and fade-out for one slide
Now we know how to make a slide show:
Also, we know how to extract frames (thumbnails) either single frame or several (periodical):
In this chapter, we'll add transition feature in-between slides, especially, fade-in and fade-out. We do this by adding fade-in first, and then will add fade-out effect to the file that has already fade-in effect.
Here are the steps:
- To do that, we need at least two pictures for each slide: A starting picture and an ending picture. We do this by copying the thumbnails from I-Frame. We have one thumbnail for the first slide, y001.png, and we want to have two pictures (in001.png and in002.png) from the slide:
copy /Y y001.png in001.png copy /Y y001.png in002.png
- We set the one slide show last 5 second by setting -r 1/5, and the framerate to be 30 so that we have 5x30=150 frames:
ffmpeg -r 1/5 -i in%03d.png -c:v libx264 -r 30 -y -pix_fmt yuv420p slide.mp4
- Then, using the output from the previous step as an input for this step, we put fade-in effect: starting 0 up to 30 frames (1 second):
ffmpeg -i slide.mp4 -y -vf fade=in:0:30 slide_fade_in.mp4
- With the slide that has fade-in, we will add fade-out effect: starting 120th frame to the end (150th frame) using the fade-in output as an input for this fade-out process:
ffmpeg -i slide_fade_in.mp4 -y -vf fade=out:120:30 slide_fade_in_out.mp4
- We may want to rename it:
copy /Y slide_fade_in_out.mp4 y001_fade.mp4
Here is the result: one slide with fade-in and fade-out effect, each for 1 second out of 5-second duration for the slide:
We can get the slides here:
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization