14

I want to create a slideshow of my images with fade in & fade out transitions between them and i am using FFmpeg fade filter.

If I use command:

ffmpeg -i input.mp4 "fade=in:5:8" output.mp4

To create the output video with fade effect, then it gives output video with first 5 frames black and than images are shown with fade in effect but i want fade:in:out effect between frame change.

How can i do that?

Please tell a solution for Centos server because i am using FFmpeg on this server only

1

3 Answers 3

7

To create a video with fade effect, just break the video into parts and create separate videos for each image. For instance, if you have 5 images then firstly, create 50-60 copies of each image and obtain a video for that:

  $command= "ffmpeg -r 20 -i images/%d.jpg -y -s 320x240 -aspect 4:3 slideshow/frame.mp4";
  exec($command." 2>&1", $output);

This will allow you to create 5 different videos. Then, you need 10-12 different copies of those five images and again create separate videos with fade effects.

ffmpeg -i input.mp4 "fade=in:5:8" output.mp4

After this you will have videos like: video for image 1 and its fade effect then for image 2 and its fade effect and so on. Now combine those videos in respective order to get the whole video.

For combining the videos you need:

$command = "cat pass.mpg slideshow/frame.mpg > final.mpg";

This means to join the videos using cat and then you need to convert them to mpg, join them and again reconvert them to mp4 or avi to view them properly. Also the converted mpg videos will not be proper so do not bother. When you convert them to mp4, it will be working fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Rather than creating multiple copies of your image files you can tell ffmpeg to loop the input. -loop 1 -i input.jpg -t 2 will tell ffmpeg to use the still image as a looping source. Because this will play forever you need to then set a time for the output video using the -t 2 option (in this case specifying 2 seconds).
3

You can make a slideshow with crossfading between the pictures, by using the framerate filter. In the following example 0.25 is the framerate used for reading in the pictures, in this case 4 seconds for each picture. The parameter fps sets the output framerate. The parameters interp_start and interp_end can be used for changing the fading effect: interp_start=128:interp_end=128 means no fading at all. interp_start=0:interp_end=255 means continuous fading. When one picture has faded out and the next picture has fully faded in, the third picture will immediately begin to fade in. There is no pause for showing the second picture. interp_start=64:interp_end=191 means half of the time is pause for showing the pictures and the other half is fading. Unfortunately it won't be a full fading from 0 to 100%, but only from 25% to 75%. That's not exactly what you might want, but better than no fading at all.

ffmpeg -framerate 0.25 -i IMG_%3d.jpg -vf "framerate=fps=30:interp_start=64:interp_end=192:scene=100" test.mp4

1 Comment

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
1

You can use gifblender to create the blended, intermediary frames from your images and then convert those to a movie with ffmpeg.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.