Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting still images to video with transitions

Tags:

imagemagick

I'd like to create a video from still images, preferably with ImageMagick and/or ffmpeg. The best guide I found is here: http://www.itforeveryone.co.uk/image-to-video.html

This sort of works but this command

convert *.JPG -delay 10 -morph 10 %05d.morph.jpg

doesn't work for me because the delay sets the time for both the still and the morph images.

I came up with this solution for a set of four images (1.jpg ... 4.jpg) with a additional black image 0.jpg:

convert -size 800x600 xc:'rgba(0,0,0,1)' 0.jpg
convert \
\( -set delay 1 0.jpg 1.jpg -morph 10 \) \
\( -set delay 60 1.jpg \) \
\( -set delay 1 1.jpg 2.jpg -morph 10 \) \
\( -set delay 60 2.jpg  \) \
\( -set delay 1 2.jpg 3.jpg -morph 10 \) \
\( -set delay 60 3.jpg         \) \
\( -set delay 1 3.jpg 4.jpg -morph 10 \) \
\( -set delay 60 4.jpg         \) \
\( -set delay 1 4.jpg 0.jpg -morph 10 \) \
 output.mpg

This does what I want except that it

  1. looks way to complicated and
  2. I obviously can't throw an '*.jpg' in there so that it works on any set of images in a directory.

Now I can python or bash my way to a script that automates this for me, but my gut feeling is that I oversaw something obvious that would turn the above script into a beautiful one-liner? Or at least something less ugly?

Thanks in advance.

like image 560
dirkk0 Avatar asked Nov 16 '12 10:11

dirkk0


2 Answers

I did not find a solution to allow throwing '*.jpg' in there. But use of -duplicate can clean it up a little. I'm using different constants than you are, but here it is:

convert \
\( 0.png 1.png -morph 23 -duplicate 25,-1 \) \
\( 1.png 2.png -morph 23 -duplicate 25,-1 \) \
\( 2.png 3.png -morph 23 -duplicate 25,-1 \) \
\( 3.png 4.png -morph 23 -duplicate 25,-1 \) \
\( 4.png 0.png -morph 23 \) \
output.mpg

I know this question is a bit old now. If, since you posted, you have found a solution that allows throwing '*.jpg' in there I would love to see it.

like image 200
Rik Renich Avatar answered Sep 27 '22 18:09

Rik Renich


I found this post after reading the same article. I was able to make it work with a hack and not something you can reliably automate. But it worked for me for the one time I'll use these instructions.

I could not get my batch of 205 sequentially numbered and same size images to convert. I would wait 10-15 minutes and nothing would appear in the output folder. I broke the processing down into batches of 100 and it would process after 2-3 minutes. I guess 205 images was too much for its brain.

This required me to adjust the output naming sequence with the -scene parameter

convert 00*.jpg -delay 10 -morph 10 frames/%05d.morph.jpg
convert 01*.jpg -delay 10 -morph 10 -scene 1079 frames/%05d.morph.jpg
convert 02*.jpg -delay 10 -morph 10 -scene 2169 frames/%05d.morph.jpg
ffmpeg -i frames/%05d.morph.jpg -c:v libx264 -vf fps=25 -pix_fmt yuv420p output.mp4
like image 22
Eric Cloninger Avatar answered Sep 27 '22 18:09

Eric Cloninger