Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFmpeg fade effects between frames

Tags:

ffmpeg

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

like image 332
Rajat Avatar asked Sep 27 '11 08:09

Rajat


1 Answers

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.

like image 84
Rajat Avatar answered Sep 17 '22 15:09

Rajat